Design System

Checkbox reference ​

Every prop, event and attribute CCheckbox accepts, and what it renders. For what the component decides, see Overview. For how to write one, see Usage.

Props ​

The component is generic over T, which defaults to boolean.

PropTypeRequiredDefaultMeaning
modelValueTYesnoneThe value, bound with v-model or with :model-value and a handler. In group mode it has to be an array
labelstringYesnoneThe text of the label, and the accessible name. Plain text, with no slot to replace it
hideLabelbooleanNofalseClips the label to a single pixel and leaves it in the accessibility tree. The label is positioned absolutely, so the row collapses to the width of the box and the 8 pixel gap goes with it
fluidbooleanNofalseFills the available width and allows the label to truncate
valueunknownNoundefinedSwitches the control into group mode. Tested with isPresent, so false and 0 count as present
trueValueunknownNotrueBinary mode. Compared with strict equality for checked-ness, and emitted when checking
falseValueunknownNofalseBinary mode. Emitted when unchecking
descriptionstringNoundefinedRenders a caption paragraph below the row and points aria-describedby at it
indeterminatebooleanNofalseDraws a dash in place of the tick and reports a mixed state. Does not set the native indeterminate property. A click resolves it to trueValue in binary mode and removes the value in group mode
disabledbooleanNofalseDisables the input, dims the box and the label, and suppresses every hover rule
readonlybooleanNofalseBlocks the change in script. Renders identically to an enabled checkbox
namestringNoundefinedLands on the input as its name attribute

id is an attribute rather than a prop. A string is taken as the input id, and anything else is ignored in favour of a generated one.

Events ​

EventPayloadDeclared
update:modelValueT. In binary mode trueValue or falseValue, in group mode a new arrayYes
changeThe native EventNo, forwarded as a listener
focusFocusEventNo, forwarded as a listener
blurFocusEventNo, forwarded as a listener
update:indeterminateboolean, emitted once when a click clears the internal mixed stateNo, forwarded as a listener
click, and any other listenerThe native event, delivered on the root element rather than on the inputNo, forwarded as a listener

A forwarded listener is untyped at the call site, so an undeclared event reaches the component library without appearing in editor completion.

Slots ​

None. The component renders no slot of its own, so text written between its tags is discarded and the label has to go through the prop.

Axes ​

None. size, severity, variant and invalid are absent from the type rather than narrowed, so the box is 20 by 20 pixels in every state and the danger branches the preset carries cannot be reached through this wrapper.

Attributes ​

The component sets inheritAttrs: false and binds an allow-list of data-*, aria-*, a listener, and the three names id, name and form, which is the layer contract in What the API accepts.

PassedDestination
data-*The root element
A listenerThe root element
aria-*The input
idThe input id, and the label for
nameThe input, through the declared prop
formThe root element, where it has no effect
class, style, pt, labelClass, inputClassDropped
binary, variant, tabindex, requiredDropped

The component spec pins the refusal with class, labelClass, inputClass and pt set at once.

DOM ​

div          the wrapper, 4px column gap, w-full under fluid
  div        the row, 8px gap, items centred
    div      the root, 20 by 20, carrying data-p-checked, data-p-indeterminate and data-p-disabled
      input  type=checkbox, absolute, opacity 0, class peer
      div    the painted box, holding the tick or the dash
    label    for the input id, caption role, sr-only under hideLabel
  p          the description, rendered only when the prop is set

ARIA ​

AttributeSet by the component
The accessible nameThe label, paired to the input by for and id
aria-describedbyOnly when description is set, pointing at the paragraph
aria-checkedSet to mixed while the control is internally indeterminate
aria-hiddenOn the dash icon, which carries no label of its own
roleNone. The native input carries the implicit checkbox role
aria-invalidNever emitted
tabindexNever emitted, so the input keeps its native tab position

Geometry ​

Pixel values below are at the default interface text setting of 14. Spacing and the box do not move with that setting, and the type and the tick do.

PartValue
Box20 by 20 pixels, 1 pixel border, 6 pixel radius
Gap, box to label8 pixels
Gap, row to description4 pixels
Height20 pixels, or 40 with a one-line description
LabelCaption role, 12 pixel type on a 16 pixel line, weight 400
DescriptionCaption role, in fg-subtle
Tick0.875rem square, 12.25 pixels at the default setting
DashInherited font size and inherited colour, since the preset icon styling does not reach it. It therefore differs from the tick in size and colour
Transition200ms on colour, over the 150ms state duration, on the standard curve
Focus indicatorA 2 pixel line-focus outline at a 2 pixel offset, drawn on the box

Colours ​

StateBorderFill
Uncheckedline-defaultsurface-page
Unchecked, hoverline-default, the token it already carriessurface-page
Checkedfill-secondaryfill-secondary
Checked, hoverfill-secondary-hoverfill-secondary-hover
Indeterminateline-defaultsurface-page

Disabled draws whichever pair applies at 0.6 opacity, and read-only draws it unchanged. fill-secondary and fg-on-secondary are single values rather than light and dark pairs, so a checked box renders the same amber in both appearances.

Measured contrast ​

Computed from the token values, converted to sRGB and put through the WCAG 2 formula. The floors are in accessibility.

PairingLightDark
The tick on the checked fill7.557.55
The tick on the checked hover fill6.227.92
The unchecked border on the page surface2.062.04
The unchecked border on a raised surface1.721.70