FAB

Floating Action Button for primary actions

Floating Action Button (FAB) component for quick access to primary actions. Supports multiple positions, sizes, labels, and custom styling.

Basic Usage

import { FAB } from 'prizmux'
import { Plus } from 'lucide-react-native'

export default function App() {
  return (
    <FAB
      onPress={() => console.log('Create new')}
      icon={<Plus size={24} color="#fff" />}
      position="bottom-right"
    />
  )
}

Props

PropTypeDefaultRequiredDescription
onPress() => voidCallback when button is pressed
iconReactNodeIcon to display
labelstringText label next to/below icon
labelPosition'right' | 'left' | 'bottom' | 'top'Position of label relative to icon
positionFABPosition'bottom-right'Position on screen
offsetXnumber16Horizontal offset from edge
offsetYnumber24Vertical offset from edge
size'small' | 'medium' | 'large''medium'FAB size (small=40, medium=56, large=72)
borderRadiusnumberBorder radius (default is circular)
backgroundColorstring'#6366F1'Background color
iconColorstringIcon color
labelColorstringLabel text color
disabledbooleanfalseDisables interaction
loadingbooleanfalseShows activity indicator
onLongPress() => voidLong press callback
styleViewStyleContainer styles
labelStyleTextStyleLabel text styles
containerStyleViewStyleAbsolute positioned wrapper styles

Positions

// bottom-right (default)
<FAB position="bottom-right" />

// bottom-left
<FAB position="bottom-left" />

// bottom-center
<FAB position="bottom-center" />

// top-right
<FAB position="top-right" />

// top-left
<FAB position="top-left" />

// top-center
<FAB position="top-center" />

Sizes

<FAB size="small" />       {/* 40px */}
<FAB size="medium" />      {/* 56px */}
<FAB size="large" />       {/* 72px */}

With Label

<FAB
  icon={<Plus size={20} />}
  label="Create"
  labelPosition="right"
  onPress={() => {}}
/>

Custom Styling

<FAB
  onPress={() => {}}
  backgroundColor="#00ff00"
  borderRadius={16}
  size="large"
  style={{ shadowOpacity: 0.3 }}
/>

Loading State

const [loading, setLoading] = useState(false)

<FAB
  onPress={async () => {
    setLoading(true)
    await createItem()
    setLoading(false)
  }}
  loading={loading}
/>