Skip to content

Settings screen in SwiftUI, Flutter, React Native and HTML/CSS

A settings list in all four targets: profile card, grouped rows, drawn toggles and a destructive action.

Open in editor

A settings screen is a stack of rows that all have to agree: labels on the left, controls or values on the right, a divider between rows, and the same corner radius on every group. We drew one at 390 by 844 (an iPhone 14) with a profile card, two grouped lists, three toggles, a value row and a sign out button, and exported it to all four targets. The code below is the generator's output, unedited. It is also the longest of these exports, because every row is its own positioned element.

What we drew

ElementPositionSizeNotes
Title, "Settings"x 24, y 72342 x 4434px, bold
Profile cardx 24, y 136342 x 88white, radius 16, 1px border
Avatarx 40, y 15256 x 56circle, blue, initials centred
Name and emailx 112, y 160 and 186230 wide17px semibold and 14px grey
"NOTIFICATIONS"x 24, y 256342 x 1612px, semibold, letter-spaced
Notification groupx 24, y 280342 x 156three rows of 52
Toggle, push (on)x 306, y 29151 x 31knob 27, at x 328
Toggle, email digest (on)x 306, y 34351 x 31knob 27, at x 328
Toggle, sound (off)x 306, y 39551 x 31knob 27, at x 308
"GENERAL"x 24, y 468342 x 16same style as the other section label
General groupx 24, y 492342 x 104two rows of 52: Language, Storage
"Sign out"x 24, y 628342 x 52outlined, red label, radius 16
Versionx 24, y 700342 x 1813px, grey, centred

The rows are 52 tall and the arithmetic is the whole design. The notification group is 156 = 3 x 52, and its row dividers sit on the row boundaries at y 331 and 383 (280 + 52 − 1 and 280 + 104 − 1), one pixel above each boundary so the line belongs to the row it closes. Each toggle is 31 tall, so it is vertically centred in its row at 11 from the top and 10 from the bottom (a 51 by 31 pill in a 52 row). The knob is 27 inside a 31 pill, which leaves a 2 inset on every side, so an off knob sits at the pill's x + 2 and an on knob at x + 51 − 27 − 2 = x + 22.

React Native

Each toggle is a Pressable holding a pill and a knob, with its own handler (togglePush, toggleDigest, toggleSound). The group wrapper is what makes a tap anywhere on the pill, including the knob, count.

import React from 'react';
import { View, Text, Pressable, StyleSheet } from 'react-native';

export default function Settings() {
  const togglePush = () => {};
  const toggleDigest = () => {};
  const toggleSound = () => {};
  const handleSignOut = () => {};

  return (
    <View style={styles.screen}>
      <Text style={styles.title}>{"Settings"}</Text>
      <View style={styles.card2} />
      <View style={styles.avatar} />
      <View style={styles.initials}><Text style={styles.initialsText}>{"AK"}</Text></View>
      <Text style={styles.label5}>{"Ada King"}</Text>
      <Text style={styles.label6}>{"[email protected]"}</Text>
      <Text style={styles.label7}>{"NOTIFICATIONS"}</Text>
      <View style={styles.card8} />
      <Text style={styles.label9}>{"Push notifications"}</Text>
      <View style={styles.ruleOne} />
      <Text style={styles.label11}>{"Email digest"}</Text>
      <View style={styles.ruleTwo} />
      <Text style={styles.label13}>{"Sound"}</Text>
      <Pressable onPress={togglePush} style={({ pressed }) => [styles.group, pressed && styles.pressed]}>
        <View style={styles.pushSwitch} />
        <View style={styles.pushKnob} />
      </Pressable>
      <Pressable onPress={toggleDigest} style={({ pressed }) => [styles.group2, pressed && styles.pressed]}>
        <View style={styles.digestSwitch} />
        <View style={styles.digestKnob} />
      </Pressable>
      <Pressable onPress={toggleSound} style={({ pressed }) => [styles.group3, pressed && styles.pressed]}>
        <View style={styles.soundSwitch} />
        <View style={styles.soundKnob} />
      </Pressable>
      <Text style={styles.label20}>{"GENERAL"}</Text>
      <View style={styles.card21} />
      <Text style={styles.label22}>{"Language"}</Text>
      <Text style={styles.label23}>{"English"}</Text>
      <Text style={styles.label24}>{"›"}</Text>
      <View style={styles.ruleThree} />
      <Text style={styles.label26}>{"Storage"}</Text>
      <Text style={styles.label27}>{"1.2 GB"}</Text>
      <Pressable onPress={handleSignOut} style={({ pressed }) => [styles.group4, pressed && styles.pressed]}>
        <View style={styles.signOut} />
        <View style={styles.signOutLabel}><Text style={styles.signOutLabelText}>{"Sign out"}</Text></View>
      </Pressable>
      <Text style={styles.label30}>{"Version 2.4.1"}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  screen: {
    flex: 1,
    backgroundColor: '#F6F4EE',
  },
  title: {
    position: 'absolute',
    left: 24,
    top: 72,
    width: 342,
    height: 44,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 34,
    lineHeight: 44,
    textAlign: 'left',
    fontWeight: '700',
  },
  card2: {
    position: 'absolute',
    left: 24,
    top: 136,
    width: 342,
    height: 88,
    borderRadius: 16,
    backgroundColor: '#ffffff',
    borderWidth: 1,
    borderColor: '#E4E1D8',
  },
  avatar: {
    position: 'absolute',
    left: 40,
    top: 152,
    width: 56,
    height: 56,
    borderRadius: 28,
    backgroundColor: '#2A50D8',
  },
  initials: {
    position: 'absolute',
    left: 40,
    top: 152,
    width: 56,
    height: 56,
    justifyContent: 'center',
  },
  initialsText: {
    color: '#ffffff',
    fontFamily: 'Inter',
    fontSize: 20,
    lineHeight: 26,
    textAlign: 'center',
    fontWeight: '600',
  },
  label5: {
    position: 'absolute',
    left: 112,
    top: 160,
    width: 230,
    height: 24,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 17,
    lineHeight: 22,
    textAlign: 'left',
    fontWeight: '600',
  },
  label6: {
    position: 'absolute',
    left: 112,
    top: 186,
    width: 230,
    height: 20,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 14,
    lineHeight: 18,
    textAlign: 'left',
  },
  label7: {
    position: 'absolute',
    left: 24,
    top: 256,
    width: 342,
    height: 16,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 12,
    lineHeight: 16,
    textAlign: 'left',
    fontWeight: '600',
    letterSpacing: 1,
  },
  card8: {
    position: 'absolute',
    left: 24,
    top: 280,
    width: 342,
    height: 156,
    borderRadius: 16,
    backgroundColor: '#ffffff',
    borderWidth: 1,
    borderColor: '#E4E1D8',
  },
  label9: {
    position: 'absolute',
    left: 40,
    top: 296,
    width: 240,
    height: 20,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'left',
  },
  ruleOne: {
    position: 'absolute',
    left: 40,
    top: 331,
    width: 326,
    height: 1,
    borderRadius: 0,
    backgroundColor: '#EDEAE0',
  },
  label11: {
    position: 'absolute',
    left: 40,
    top: 348,
    width: 240,
    height: 20,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'left',
  },
  ruleTwo: {
    position: 'absolute',
    left: 40,
    top: 383,
    width: 326,
    height: 1,
    borderRadius: 0,
    backgroundColor: '#EDEAE0',
  },
  label13: {
    position: 'absolute',
    left: 40,
    top: 400,
    width: 240,
    height: 20,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'left',
  },
  group: {
    position: 'absolute',
    left: 306,
    top: 291,
    width: 51,
    height: 31,
  },
  pushSwitch: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: 51,
    height: 31,
    borderRadius: 16,
    backgroundColor: '#2A50D8',
  },
  pushKnob: {
    position: 'absolute',
    left: 22,
    top: 2,
    width: 27,
    height: 27,
    borderRadius: 14,
    backgroundColor: '#ffffff',
    shadowColor: '#000000',
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 1,
    shadowRadius: 3,
    elevation: 3,
  },
  group2: {
    position: 'absolute',
    left: 306,
    top: 343,
    width: 51,
    height: 31,
  },
  digestSwitch: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: 51,
    height: 31,
    borderRadius: 16,
    backgroundColor: '#2A50D8',
  },
  digestKnob: {
    position: 'absolute',
    left: 22,
    top: 2,
    width: 27,
    height: 27,
    borderRadius: 14,
    backgroundColor: '#ffffff',
    shadowColor: '#000000',
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 1,
    shadowRadius: 3,
    elevation: 3,
  },
  group3: {
    position: 'absolute',
    left: 306,
    top: 395,
    width: 51,
    height: 31,
  },
  soundSwitch: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: 51,
    height: 31,
    borderRadius: 16,
    backgroundColor: '#D7D3C8',
  },
  soundKnob: {
    position: 'absolute',
    left: 2,
    top: 2,
    width: 27,
    height: 27,
    borderRadius: 14,
    backgroundColor: '#ffffff',
    shadowColor: '#000000',
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 1,
    shadowRadius: 3,
    elevation: 3,
  },
  label20: {
    position: 'absolute',
    left: 24,
    top: 468,
    width: 342,
    height: 16,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 12,
    lineHeight: 16,
    textAlign: 'left',
    fontWeight: '600',
    letterSpacing: 1,
  },
  card21: {
    position: 'absolute',
    left: 24,
    top: 492,
    width: 342,
    height: 104,
    borderRadius: 16,
    backgroundColor: '#ffffff',
    borderWidth: 1,
    borderColor: '#E4E1D8',
  },
  label22: {
    position: 'absolute',
    left: 40,
    top: 508,
    width: 160,
    height: 20,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'left',
  },
  label23: {
    position: 'absolute',
    left: 200,
    top: 508,
    width: 132,
    height: 20,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'right',
  },
  label24: {
    position: 'absolute',
    left: 338,
    top: 508,
    width: 16,
    height: 20,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'center',
  },
  ruleThree: {
    position: 'absolute',
    left: 40,
    top: 543,
    width: 326,
    height: 1,
    borderRadius: 0,
    backgroundColor: '#EDEAE0',
  },
  label26: {
    position: 'absolute',
    left: 40,
    top: 560,
    width: 160,
    height: 20,
    color: '#17171A',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'left',
  },
  label27: {
    position: 'absolute',
    left: 200,
    top: 560,
    width: 132,
    height: 20,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'right',
  },
  group4: {
    position: 'absolute',
    left: 24,
    top: 628,
    width: 342,
    height: 52,
  },
  signOut: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: 342,
    height: 52,
    borderRadius: 16,
    backgroundColor: '#ffffff',
    borderWidth: 1,
    borderColor: '#E4E1D8',
  },
  signOutLabel: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: 342,
    height: 52,
    justifyContent: 'center',
  },
  signOutLabelText: {
    color: '#D93B3B',
    fontFamily: 'Inter',
    fontSize: 16,
    lineHeight: 21,
    textAlign: 'center',
    fontWeight: '600',
  },
  label30: {
    position: 'absolute',
    left: 24,
    top: 700,
    width: 342,
    height: 18,
    color: '#5B5B63',
    fontFamily: 'Inter',
    fontSize: 13,
    lineHeight: 18,
    textAlign: 'center',
  },
  pressed: {
    opacity: 0.6,
  },
});

What this does not do

  • These are drawn toggles, not platform switches. A pill and a knob look like a switch, but they are rectangles and a circle inside a button. They do not expose an on/off state to a screen reader and do not animate. In your project, swap them for your platform's own switch (Switch, Toggle, a checkbox input) positioned at the same coordinates.
  • State is yours. The on and off positions here are just where the knobs were drawn. The handlers are empty, and nothing flips when you tap.
  • Rows do not reflow. If you add a row, every element below it needs to move down. The positions are literal, which is also why each one can be read straight off the canvas.
  • Disclosure arrows are text. The arrow after "English" is a text character, not a platform chevron.
  • Fixed size and fonts by name. 390 by 844, and Inter is not embedded.

Make your own

Open the editor, change any number, and the four files above change with it. What you can build lists every control and property the canvas supports, limits included.