X Enterprises
Inline

InlineToggle

Toggle switch that immediately persists a boolean field change via useXCrud.

Inline

The Inline category provides click-to-edit field components for detail views and data tables. Each component follows the same pattern: display mode (read-only with a subtle hover affordance) → edit mode → optimistic save via useXCrud → success/error indicator. All rollback on API failure.

Components

<XAInlineToggle />

A USwitch that immediately PATCHes a boolean field on toggle. Optimistically updates the value then reverts on API failure. Shows a text label next to the switch that reflects the current state.

<XAInlineToggle
  v-model="record.isActive"
  field="isActive"
  endpoint="/api/records"
  :entity-id="record.id"
  true-label="Active"
  false-label="Inactive"
  :show-label="true"
  size="sm"
  @save="onToggled"
/>

Props

PropTypeDefaultDescription
modelValueBooleanfalseCurrent boolean value (v-model)
fieldStringrequiredField name to update
endpointStringrequiredAPI endpoint for useXCrud
entityIdString | NumberrequiredRecord ID
trueLabelString'Yes'Label text when value is true
falseLabelString'No'Label text when value is false
showLabelBooleantrueShow text label next to switch
labelClassString'text-sm'Additional CSS classes for the label
size'xs' | 'sm' | 'md' | 'lg''sm'Switch size

Emits

EventPayloadDescription
update:modelValueBooleanOptimistic value update
savenewValue, previousValueSave succeeded
errorErrorSave failed

AI Context

component: XAInlineToggle
package: "@xenterprises/nuxt-x-app"
category: Inline
auto-import: true
use-when: >
  Detail pages where users should be able to toggle boolean flags (active/inactive,
  enabled/disabled) without navigating to a separate edit form.
key-patterns:
  - Requires field, endpoint, and entityId props
  - Uses useXCrud internally — no manual API call needed
  - Performs optimistic updates and reverts on failure
  - Use v-model to keep the parent state in sync
Copyright © 2026