norn-choice
Checkboxes or radios in a fieldset, named by its legend. Each option is a <label> holding its native input, then its text, so a click anywhere on the label sets it. The boxes are drawn at 1.25em with a strong edge and a hover layer; a checked one fills with the accent and shows a tick or a dot. Give a radio group one name. In forced colors the native controls return. For one choice from a few drawn as a single control, use norn-segmented-control.
<norn-choice>
a component , from
@allons-y/webc-patterns
Examples
Open on its own
Source
<norn-choice>
<template slot="legend" webc:nokeep><span>Reply by</span></template>
<label><input type="radio" name="reply" value="email" checked /> Email</label>
<label><input type="radio" name="reply" value="phone" /> Phone</label>
<label><input type="radio" name="reply" value="none" /> No reply needed</label>
</norn-choice>
Copy {name} to clipboard
Copy
Copied
Copy failed
html code
Open on its own
Source
<norn-choice>
<template slot="legend" webc:nokeep><span>Topics</span></template>
<label><input type="checkbox" name="topics" value="css" checked /> CSS</label>
<label><input type="checkbox" name="topics" value="a11y" /> Accessibility</label>
<label><input type="checkbox" name="topics" value="components" disabled /> Web components (full)</label>
</norn-choice>
Copy {name} to clipboard
Copy
Copied
Copy failed
html code
Open on its own
Source
<norn-choice @inline>
<template slot="legend" webc:nokeep><span>Size</span></template>
<label><input type="radio" name="size" value="s" /> Small</label>
<label><input type="radio" name="size" value="m" checked /> Medium</label>
<label><input type="radio" name="size" value="l" /> Large</label>
</norn-choice>
Copy {name} to clipboard
Copy
Copied
Copy failed
html code
Open on its own
Source
<div style="display: grid; gap: 1.5rem">
<div style="display: grid; gap: 0.5rem">
<p><code>inline = true</code></p>
<div>
<norn-choice @inline>
<template slot="legend" webc:nokeep><span>Reply by</span></template>
<label><input type="radio" name="reply" value="email" checked /> Email</label>
<label><input type="radio" name="reply" value="phone" /> Phone</label>
<label><input type="radio" name="reply" value="none" /> No reply needed</label>
</norn-choice>
</div>
</div>
<div style="display: grid; gap: 0.5rem">
<p><code>inline = false</code></p>
<div>
<norn-choice>
<template slot="legend" webc:nokeep><span>Reply by</span></template>
<label><input type="radio" name="reply" value="email" checked /> Email</label>
<label><input type="radio" name="reply" value="phone" /> Phone</label>
<label><input type="radio" name="reply" value="none" /> No reply needed</label>
</norn-choice>
</div>
</div>
</div>
Copy {name} to clipboard
Copy
Copied
Copy failed
html code
Props
Write them with the @ prefix, and :@ for an expression.
Name Type Description
@inline
boolean
Sets the options in a wrapping row instead of a column.
Slots
Name Description
legend
The group's name, as one element, such as <span slot="legend">Reply by</span>. Required: the build fails without it.
default
The options: each a <label> holding an <input type="checkbox"> or <input type="radio">, then its text.
Tokens
The global tokens from tokens.json the component reads. Set one in a project's tokens.css to change it everywhere.
Type a value to try it in every example above. Reset puts the default back.
Token
Type
Default
Override
--norn-ui-accentThe brand color, shared by every component.
<color>
#2346d4
Reset
--norn-ui-border-colorHairline color.
<color>
light-dark(#d3d8e2, #2d323e)
Reset
--norn-ui-border-strongEdge of a control, such as a field. At least 3:1 on the page surface, which WCAG 1.4.11 asks of a control's boundary.
<color>
light-dark(#7a8194, #6f7789)
Reset
--norn-ui-radius-sCorner radius of a part inside a component, and of inline code. A component's own radius is ui.border.radius.
<length>
4px
Reset
--norn-ui-state-hoverShare of the text color mixed into the background while the pointer is over a control.
<percentage>
8%
Reset
--norn-ui-state-pressShare of the text color mixed into the background while a control is pressed, and of the accent on a selected or current item.
<percentage>
12%
Reset
--norn-ui-motion-durationLength of a state change, such as a hover layer.
<time>
150ms
Reset
--norn-ui-motion-easingEasing for every transition.
<easing-function>
cubic-bezier(0.2, 0, 0, 1)
Reset
--norn-surface-basePage surface. Light and dark values.
<color>
light-dark(#ffffff, #101216)
Reset
--norn-surface-raisedRaised surface.
<color>
light-dark(hsl(40, 14%, 96%), #242932)
Reset
--norn-text-mutedSecondary text color.
<color>
light-dark(#4b5160, #a4abba)
Reset
--norn-text-on-accentBlack or white text for an accent background, whichever contrasts more: at least 4.58:1. Switches at relative luminance 0.1791.
<color>
color(from var(--norn-ui-accent, #2346d4) xyz-d65 calc(0.95047 * clamp(0, calc((0.1791 - y) * 1000000), 1)) clamp(0, calc((0.1791 - y) * 1000000), 1) calc(1.08883 * clamp(0, calc((0.1791 - y) * 1000000), 1)))
Reset
--norn-space-xsExtra small spacing step.
<length>
0.5rem
Reset
--norn-space-mMedium spacing step.
<length>
1.25rem
Reset
--norn-status-dangerDanger. The color of a caution and an error.
<color>
light-dark(#b42318, #ff8a80)
Reset