Components/FlatRadio
Since 2.4.7BETA

FlatRadio

Inline flat selector for 2-5 options (`TxFlatRadio` + `TxFlatRadioItem`). Provides sliding indicator animation, keyboard navigation, and full TypeScript support.

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

FlatRadio

Inline flat selector for 2-5 options (TxFlatRadio + TxFlatRadioItem). More direct than dropdown selectors, more compact than Radio.

Basic Usage

The simplest flat selector, ideal for a small number of options.

FlatRadio (basic)

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const value = ref<'light' | 'dark' | 'auto'>('light')
</script>

<template>
  <TxFlatRadio v-model="value">
    <TxFlatRadioItem value="light" label="Light" />
    <TxFlatRadioItem value="dark" label="Dark" />
    <TxFlatRadioItem value="auto" label="Auto" />
  </TxFlatRadio>
</template>

Sizes

Supports sm, md (default), and lg sizes.

FlatRadio (sizes)

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const sm = ref('a')
const md = ref('a')
const lg = ref('a')
</script>

<template>
  <TxFlatRadio v-model="sm" size="sm">
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>

  <TxFlatRadio v-model="md" size="md">
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>

  <TxFlatRadio v-model="lg" size="lg">
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>
</template>

Icons

Use the icon prop to add icons to options (CSS class, e.g. UnoCSS icons).

FlatRadio (icon)

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const value = ref('grid')
</script>

<template>
  <TxFlatRadio v-model="value">
    <TxFlatRadioItem value="grid" icon="i-carbon-grid" label="Grid" />
    <TxFlatRadioItem value="list" icon="i-carbon-list" label="List" />
    <TxFlatRadioItem value="kanban" icon="i-carbon-column" label="Kanban" />
  </TxFlatRadio>
</template>

Disabled State

Supports both group-level and item-level disabling.

FlatRadio (disabled)

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const value = ref('a')
</script>

<template>
  <!-- Item disabled -->
  <TxFlatRadio v-model="value">
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" disabled />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>

  <!-- Group disabled -->
  <TxFlatRadio v-model="value" disabled>
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>
</template>

Bordered

Set the bordered prop to add an outer border.

FlatRadio (bordered)

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const value = ref('a')
</script>

<template>
  <TxFlatRadio v-model="value" bordered>
    <TxFlatRadioItem value="a" label="Option A" />
    <TxFlatRadioItem value="b" label="Option B" />
    <TxFlatRadioItem value="c" label="Option C" />
  </TxFlatRadio>
</template>

Keyboard Navigation

When the container is focused:

KeyBehavior
/ Select next non-disabled item (wraps)
/ Select previous non-disabled item (wraps)
HomeSelect first non-disabled item
EndSelect last non-disabled item
Enter / SpaceIn multiple mode, toggle the currently focused item

API

TxFlatRadio

Props

PropDescriptionTypeDefault
modelValue / v-modelSelected value in single mode, or selected value array in multiple mode.string | number | (string | number)[]-
multipleEnables checkbox-like multi-select behavior. The sliding single-select indicator is hidden in this mode.booleanfalse
disabledDisables the entire group, removes focusability, and blocks keyboard changes.booleanfalse
sizeSize variant'sm' | 'md' | 'lg''md'
borderedAdds an outer border around the selector.booleanfalse

Events

EventDescriptionParams
update:modelValueEmitted with the next selected value or selected value array.(value: string | number | (string | number)[]) => void
changeEmitted with the same payload after a selection change.(value: string | number | (string | number)[]) => void

Slots

SlotDescription
defaultTxFlatRadioItem children

TxFlatRadioItem

Props

PropDescriptionTypeDefault
valueItem value used by the parent model.string | number-
labelFallback visible text when no default slot is provided.string-
iconFallback icon CSS class when no icon slot is provided.string-
disabledDisables this item and skips it during keyboard navigation.booleanfalse

Slots

SlotDescription
defaultCustom visible item content, replacing label.
iconCustom icon content, replacing the icon class.