Skip to content

Represents a single choice in exclusive options.

import { BbRadio } from 'bitboss-ui';

On this page

Props

NameTypeDefaultDescription
autofocusBooleanish | undefined-

Sets autofocus on page load.

checkedboolean | undefined-

Defines the input as checked.

Overrides the model-derived display and fights a v-model — pick one source of truth. Narrowed to a plain boolean in v3, so the v2 string forms no longer compile.

descriptionstring | undefined-

Descriptive text displayed below the label and above the input. Unlike the hint it is always visible, and it is linked to the input via aria-describedby (after any errors / warnings, before the hint).

Wired into the input's aria-describedby, so it is announced as part of the option. The same sentence in a sibling element is read as unrelated page content.

See example
directionInputDirection | undefined"auto"

Direction of the layout of the component. Can either be a predefined value or a pattern separated by a space like xx xxxxx.

disabledboolean | undefinedfalse

Disables the component.

Removes the option from the tab order and from the post. Prefer offering a real choice; when you cannot, say why in description.

See example
errorsstring | string[] | undefined-

Can be a string or an array of string containing the messages to display. They render in an aria-live="polite" region (announced when they appear) and, while the list is non-empty, are referenced FIRST from the control's aria-describedby, so the reason the field is invalid is re-read whenever the control regains focus.

Lives on one button, while the error usually belongs to the whole set. Put it on a single radio rather than on each one — repeated, it renders and announces the same sentence per button. A set that needs validation is an argument for BbRadioGroup.

See example
hasErrorsboolean | undefinedfalse

Define if the component should be in an error state. It usually attaches a CSS class for styling purposes.

See example
hasWarningsboolean | undefinedfalse

Define if the component should be in a warning state. Same chrome as errors with --bb-warn; errors take priority.

hideLabelboolean | undefinedfalse

Visually hides the label of the input while maintaining accessibility.

hintstring | undefined-

Text box to be displayed near the input, usually to indicate instructions.

idstring | undefined-

The identifier of the component.

inputPosition"left" | "center" | "right" | undefined"left"

Sets the alignment of the input. Since inputs are inline block they can be aligned just as text can.

labelrequiredstring-

Text content of the label of the element.

Required on every button: it is the accessible name, and it stays the accessible name when the label slot replaces the rendered text.

See example
labelPosition"left" | "center" | "right" | undefined-

Sets the text alignment of the label.

modelValueany-

Used by v-model. Can be any serializable type.

namestring | undefined-

Defines the name of the input. Optional: an omitted name falls back to a generated one, unique to this button and stable for its lifetime, so a lone radio needs no name at all. Buttons that must form ONE exclusive group still have to share an explicit name — generated names are per-instance, so they would never group. Pass a name too when the value has to be submitted under a known key by a native (non-JS) form post.

No longer required in v3 — an omitted name is generated per button. That is exactly why a hand-composed group must still pass one shared explicit name: generated names differ, so those buttons never form a native group and you lose exclusivity and arrow-key navigation with it.

See example
persistentHintboolean | undefinedfalse

Keeps the hint displayed.

ptPtMap<TogglePtPart, TogglePtState> | undefined-

Passthrough, object form: the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:descriptionPtValue | undefined-
pt:description:checkedPtValue | undefined-
pt:description:disabledPtValue | undefined-
pt:description:errorsPtValue | undefined-
pt:description:focus-visiblePtValue | undefined-
pt:description:focusedPtValue | undefined-
pt:description:readonlyPtValue | undefined-
pt:description:warningsPtValue | undefined-
pt:hintPtValue | undefined-
pt:hint:checkedPtValue | undefined-
pt:hint:disabledPtValue | undefined-
pt:hint:errorsPtValue | undefined-
pt:hint:focus-visiblePtValue | undefined-
pt:hint:focusedPtValue | undefined-
pt:hint:readonlyPtValue | undefined-
pt:hint:warningsPtValue | undefined-
pt:iconPtValue | undefined-
pt:icon:checkedPtValue | undefined-
pt:icon:disabledPtValue | undefined-
pt:icon:errorsPtValue | undefined-
pt:icon:focus-visiblePtValue | undefined-
pt:icon:focusedPtValue | undefined-
pt:icon:readonlyPtValue | undefined-
pt:icon:warningsPtValue | undefined-
pt:labelPtValue | undefined-
pt:label:checkedPtValue | undefined-
pt:label:disabledPtValue | undefined-
pt:label:errorsPtValue | undefined-
pt:label:focus-visiblePtValue | undefined-
pt:label:focusedPtValue | undefined-
pt:label:readonlyPtValue | undefined-
pt:label:warningsPtValue | undefined-
pt:messagePtValue | undefined-
pt:message:checkedPtValue | undefined-
pt:message:disabledPtValue | undefined-
pt:message:errorsPtValue | undefined-
pt:message:focus-visiblePtValue | undefined-
pt:message:focusedPtValue | undefined-
pt:message:readonlyPtValue | undefined-
pt:message:warningsPtValue | undefined-
pt:rootPtValue | undefined-
pt:root:checkedPtValue | undefined-
pt:root:disabledPtValue | undefined-
pt:root:errorsPtValue | undefined-
pt:root:focus-visiblePtValue | undefined-
pt:root:focusedPtValue | undefined-
pt:root:readonlyPtValue | undefined-
pt:root:warningsPtValue | undefined-
readonlyboolean | undefinedfalse

Sets the input in a readonly state.

Blocks changes while staying focusable and still submitting. A lone radio cannot announce it — role="radio" supports no aria-readonly — so explain it in description, or use BbRadioGroup, whose radiogroup does carry the attribute.

See example
requiredboolean | undefinedfalse

Sets the input as required.

reverseboolean | undefinedfalse

Reverses the layout: in every direction the order of the label and the input is swapped from the standard arrangement.

Its meaning inverted in v3 and the compiler cannot see it. The default rendering is unchanged, but a v2 :reverse="false" becomes a bare reverse, and a v2 reverse is deleted.

valuerequiredany-

Defines the value of the radio input. It can be any serializable value.

Required, and distinct per button — two buttons sharing a value are not two options. Any serializable value is matched structurally, but prefer stable primitive ids: they survive a refetch and are cheap to submit.

See example
warningsstring | string[] | undefined-

Warning messages to display beneath the field, in their own aria-live region and amber (--bb-text-warn). A string or array; a non-empty list implies the warning state. Errors suppress warnings when both are set. While displayed they are also referenced from the control's aria-describedby, after any errors and before the description/hint.

v-model

Values kept in sync through v-model.

NameTypeDescription
modelValueany

One model shared by every button in the set: that is what makes selecting one deselect the rest. It carries the chosen value and nothing else.

See example

Events

NameTypeDescription
blur(event: "blur", event: FocusEvent): void
change(event: "change", event: Event): void
click(event: "click", event: MouseEvent): void
focus(event: "focus", event: FocusEvent): void
input(event: "input", event: Event): void
keydown(event: "keydown", event: KeyboardEvent): void
mousedown(event: "mousedown", event: MouseEvent): void
mouseup(event: "mouseup", event: MouseEvent): void
update:modelValue(event: "update:modelValue", value: any): void

Slots

The listed properties are the ones exposed to the slot scope.

NameTypeDescription
descriptionBbRadioDescriptionSlotProps

Replaces the description text. Provided alone (no description prop) it still renders the description region and wires it into aria-describedby.

iconBbRadioIconSlotProps

Replaces the default radio dot visual inside the radio container. Receives the radio state plus the label text.

Replaces the whole radio-dot visual, so the slot owns selected, unselected and the focus ring. When the row around it is the problem rather than the dot, drop to BbBaseRadioIcon.

See example
labelBbRadioLabelSlotProps

Replaces the default label text rendered next to the radio button.

Receives { text, hasErrors, hasWarnings }. Use it for the one option that needs a badge or emphasis — if every option needs the same decoration, you have a uniform mapping again and BbRadioGroup expresses it with less markup.

See example

Changes from v2

Props removed or renamed in 3.0. If you are coming from v2, the answer is here.

  • colorremovedfails silently
  • hasWarninghasWarningsfails silently