Skip to content

Selection controls

Forms
Selection controls

Checkbox

Switch

Radio group

Three-column composition showing Checkbox, Switch, and radio-style option lists in realistic settings patterns.

checkbox · switch · field · stack · grid
import { Grid } from "@/components/ui/grid"
import { Stack } from "@/components/ui/stack"
import { Field, FieldLabel } from "@/components/ui/field"
import { Checkbox } from "@/components/ui/checkbox"
import { Switch } from "@/components/ui/switch"

export function SelectionControls() {
  return (
    <Grid className="grid-cols-3 gap-7">
      <Stack direction="col" gap="4">
        <p className="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Checkbox</p>
        <Stack direction="col" gap="3">
          <Field orientation="horizontal">
            <Checkbox id="cb1" checked />
            <FieldLabel htmlFor="cb1">Enable streaming responses</FieldLabel>
          </Field>
          <Field orientation="horizontal">
            <Checkbox id="cb2" />
            <FieldLabel htmlFor="cb2">Allow guest edits</FieldLabel>
          </Field>
          <Field orientation="horizontal" className="opacity-50">
            <Checkbox id="cb3" checked disabled />
            <FieldLabel htmlFor="cb3">Legacy sync (enterprise)</FieldLabel>
          </Field>
        </Stack>
      </Stack>
      <Stack direction="col" gap="4">
        <p className="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Switch</p>
        <Stack direction="col" gap="3">
          <Field orientation="horizontal">
            <Switch id="sw1" checked />
            <FieldLabel htmlFor="sw1">Claude suggestions</FieldLabel>
          </Field>
          <Field orientation="horizontal">
            <Switch id="sw2" />
            <FieldLabel htmlFor="sw2">Auto-run effects in dev</FieldLabel>
          </Field>
          <Field orientation="horizontal">
            <Switch id="sw3" checked />
            <FieldLabel htmlFor="sw3">Telemetry</FieldLabel>
          </Field>
        </Stack>
      </Stack>
      <Stack direction="col" gap="4">
        <p className="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Radio group</p>
        <Stack direction="col" gap="3">
          <Field orientation="horizontal">
            <Checkbox id="rd1" checked />
            <FieldLabel htmlFor="rd1">Free — up to 3 machines</FieldLabel>
          </Field>
          <Field orientation="horizontal">
            <Checkbox id="rd2" />
            <FieldLabel htmlFor="rd2">Pro · $19/mo</FieldLabel>
          </Field>
          <Field orientation="horizontal" className="opacity-50">
            <Checkbox id="rd3" disabled />
            <FieldLabel htmlFor="rd3">Enterprise</FieldLabel>
          </Field>
        </Stack>
      </Stack>
    </Grid>
  )
}
ui26/react
<script lang="ts">
  import Grid from "$lib/components/ui/grid.svelte"
  import Stack from "$lib/components/ui/stack.svelte"
  import Field from "$lib/components/ui/field.svelte"
  import Checkbox from "$lib/components/ui/checkbox.svelte"
  import FieldLabel from "$lib/components/ui/field-label.svelte"
  import Switch from "$lib/components/ui/switch.svelte"
</script>

<Grid class="grid-cols-3 gap-7">
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Checkbox</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Checkbox id="cb1" checked />
        <FieldLabel htmlFor="cb1">Enable streaming responses</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Checkbox id="cb2" />
        <FieldLabel htmlFor="cb2">Allow guest edits</FieldLabel>
      </Field>
      <Field orientation="horizontal" class="opacity-50">
        <Checkbox id="cb3" checked disabled />
        <FieldLabel htmlFor="cb3">Legacy sync (enterprise)</FieldLabel>
      </Field>
    </Stack>
  </Stack>
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Switch</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Switch id="sw1" checked />
        <FieldLabel htmlFor="sw1">Claude suggestions</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Switch id="sw2" />
        <FieldLabel htmlFor="sw2">Auto-run effects in dev</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Switch id="sw3" checked />
        <FieldLabel htmlFor="sw3">Telemetry</FieldLabel>
      </Field>
    </Stack>
  </Stack>
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Radio group</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Checkbox id="rd1" checked />
        <FieldLabel htmlFor="rd1">Free — up to 3 machines</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Checkbox id="rd2" />
        <FieldLabel htmlFor="rd2">Pro · $19/mo</FieldLabel>
      </Field>
      <Field orientation="horizontal" class="opacity-50">
        <Checkbox id="rd3" disabled />
        <FieldLabel htmlFor="rd3">Enterprise</FieldLabel>
      </Field>
    </Stack>
  </Stack>
</Grid>
ui26/svelte
---
import Grid from "@/components/ui/grid.astro"
import Stack from "@/components/ui/stack.astro"
import Field from "@/components/ui/field.astro"
import Checkbox from "@/components/ui/checkbox.astro"
import FieldLabel from "@/components/ui/field-label.astro"
import Switch from "@/components/ui/switch.astro"
---

<Grid class="grid-cols-3 gap-7">
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Checkbox</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Checkbox id="cb1" checked />
        <FieldLabel htmlFor="cb1">Enable streaming responses</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Checkbox id="cb2" />
        <FieldLabel htmlFor="cb2">Allow guest edits</FieldLabel>
      </Field>
      <Field orientation="horizontal" class="opacity-50">
        <Checkbox id="cb3" checked disabled />
        <FieldLabel htmlFor="cb3">Legacy sync (enterprise)</FieldLabel>
      </Field>
    </Stack>
  </Stack>
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Switch</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Switch id="sw1" checked />
        <FieldLabel htmlFor="sw1">Claude suggestions</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Switch id="sw2" />
        <FieldLabel htmlFor="sw2">Auto-run effects in dev</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Switch id="sw3" checked />
        <FieldLabel htmlFor="sw3">Telemetry</FieldLabel>
      </Field>
    </Stack>
  </Stack>
  <Stack direction="col" gap="4">
    <p class="text-xs font-mono uppercase tracking-[0.06em] text-muted-foreground">Radio group</p>
    <Stack direction="col" gap="3">
      <Field orientation="horizontal">
        <Checkbox id="rd1" checked />
        <FieldLabel htmlFor="rd1">Free — up to 3 machines</FieldLabel>
      </Field>
      <Field orientation="horizontal">
        <Checkbox id="rd2" />
        <FieldLabel htmlFor="rd2">Pro · $19/mo</FieldLabel>
      </Field>
      <Field orientation="horizontal" class="opacity-50">
        <Checkbox id="rd3" disabled />
        <FieldLabel htmlFor="rd3">Enterprise</FieldLabel>
      </Field>
    </Stack>
  </Stack>
</Grid>
ui26/astro
{
  "root": "col-grid",
  "elements": {
    "col-grid": {
      "type": "Grid",
      "props": {
        "className": "grid-cols-3 gap-7"
      },
      "children": [
        "checkbox-col",
        "switch-col",
        "radio-col"
      ]
    },
    "checkbox-col": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "4"
      },
      "children": [
        "cb-heading",
        "cb-list"
      ]
    },
    "cb-heading": {
      "type": "Text",
      "props": {
        "content": "Checkbox",
        "mono": true,
        "size": "xs",
        "className": "uppercase tracking-[0.06em] text-muted-foreground"
      },
      "children": []
    },
    "cb-list": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "3"
      },
      "children": [
        "cb-item1",
        "cb-item2",
        "cb-item3"
      ]
    },
    "cb-item1": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "cb1",
        "cb-lbl1"
      ]
    },
    "cb1": {
      "type": "Checkbox",
      "props": {
        "id": "cb1",
        "checked": true
      },
      "children": []
    },
    "cb-lbl1": {
      "type": "FieldLabel",
      "props": {
        "text": "Enable streaming responses",
        "htmlFor": "cb1"
      },
      "children": []
    },
    "cb-item2": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "cb2",
        "cb-lbl2"
      ]
    },
    "cb2": {
      "type": "Checkbox",
      "props": {
        "id": "cb2"
      },
      "children": []
    },
    "cb-lbl2": {
      "type": "FieldLabel",
      "props": {
        "text": "Allow guest edits",
        "htmlFor": "cb2"
      },
      "children": []
    },
    "cb-item3": {
      "type": "Field",
      "props": {
        "orientation": "horizontal",
        "className": "opacity-50"
      },
      "children": [
        "cb3",
        "cb-lbl3"
      ]
    },
    "cb3": {
      "type": "Checkbox",
      "props": {
        "id": "cb3",
        "checked": true,
        "disabled": true
      },
      "children": []
    },
    "cb-lbl3": {
      "type": "FieldLabel",
      "props": {
        "text": "Legacy sync (enterprise)",
        "htmlFor": "cb3"
      },
      "children": []
    },
    "switch-col": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "4"
      },
      "children": [
        "sw-heading",
        "sw-list"
      ]
    },
    "sw-heading": {
      "type": "Text",
      "props": {
        "content": "Switch",
        "mono": true,
        "size": "xs",
        "className": "uppercase tracking-[0.06em] text-muted-foreground"
      },
      "children": []
    },
    "sw-list": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "3"
      },
      "children": [
        "sw-item1",
        "sw-item2",
        "sw-item3"
      ]
    },
    "sw-item1": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "sw1",
        "sw-lbl1"
      ]
    },
    "sw1": {
      "type": "Switch",
      "props": {
        "id": "sw1",
        "checked": true
      },
      "children": []
    },
    "sw-lbl1": {
      "type": "FieldLabel",
      "props": {
        "text": "Claude suggestions",
        "htmlFor": "sw1"
      },
      "children": []
    },
    "sw-item2": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "sw2",
        "sw-lbl2"
      ]
    },
    "sw2": {
      "type": "Switch",
      "props": {
        "id": "sw2"
      },
      "children": []
    },
    "sw-lbl2": {
      "type": "FieldLabel",
      "props": {
        "text": "Auto-run effects in dev",
        "htmlFor": "sw2"
      },
      "children": []
    },
    "sw-item3": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "sw3",
        "sw-lbl3"
      ]
    },
    "sw3": {
      "type": "Switch",
      "props": {
        "id": "sw3",
        "checked": true
      },
      "children": []
    },
    "sw-lbl3": {
      "type": "FieldLabel",
      "props": {
        "text": "Telemetry",
        "htmlFor": "sw3"
      },
      "children": []
    },
    "radio-col": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "4"
      },
      "children": [
        "rd-heading",
        "rd-list"
      ]
    },
    "rd-heading": {
      "type": "Text",
      "props": {
        "content": "Radio group",
        "mono": true,
        "size": "xs",
        "className": "uppercase tracking-[0.06em] text-muted-foreground"
      },
      "children": []
    },
    "rd-list": {
      "type": "Stack",
      "props": {
        "direction": "col",
        "gap": "3"
      },
      "children": [
        "rd-item1",
        "rd-item2",
        "rd-item3"
      ]
    },
    "rd-item1": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "rd1",
        "rd-lbl1"
      ]
    },
    "rd1": {
      "type": "Checkbox",
      "props": {
        "id": "rd1",
        "checked": true
      },
      "children": []
    },
    "rd-lbl1": {
      "type": "FieldLabel",
      "props": {
        "text": "Free — up to 3 machines",
        "htmlFor": "rd1"
      },
      "children": []
    },
    "rd-item2": {
      "type": "Field",
      "props": {
        "orientation": "horizontal"
      },
      "children": [
        "rd2",
        "rd-lbl2"
      ]
    },
    "rd2": {
      "type": "Checkbox",
      "props": {
        "id": "rd2"
      },
      "children": []
    },
    "rd-lbl2": {
      "type": "FieldLabel",
      "props": {
        "text": "Pro · $19/mo",
        "htmlFor": "rd2"
      },
      "children": []
    },
    "rd-item3": {
      "type": "Field",
      "props": {
        "orientation": "horizontal",
        "className": "opacity-50"
      },
      "children": [
        "rd3",
        "rd-lbl3"
      ]
    },
    "rd3": {
      "type": "Checkbox",
      "props": {
        "id": "rd3",
        "disabled": true
      },
      "children": []
    },
    "rd-lbl3": {
      "type": "FieldLabel",
      "props": {
        "text": "Enterprise",
        "htmlFor": "rd3"
      },
      "children": []
    }
  }
}
ui26/json-render