FlavorPicker
FlavorPicker displays flavor definitions and lets someone choose a palette. use the registered global collection for an app setting, or pass an explicit collection for a local draft preview.
Collection preview
pick a palette for this draft.
Draft palette: paper
usage
<script>
import { FlavorPicker } from '@ciabi/loafkit-ui';
let selected = $state('paper');
const flavors = [
{ name: 'paper', description: 'Warm pages', isDark: false,
cssVariables: { '--loaf-surface': '#FFFDF7', '--loaf-text': '#292720', '--loaf-accent': '#566B3A' } },
{ name: 'ink', description: 'Evening reading', isDark: true,
cssVariables: { '--loaf-surface': '#191D20', '--loaf-text': '#F1EEE5', '--loaf-accent': '#B5CA8A' } }
];
</script>
<FlavorPicker pickerOnly {flavors} {selected} title="Collection preview"
description="pick a palette for this draft." onSelect={definition => selected = definition.name} />
<p>Draft palette: {selected}</p>global mode
register your definitions and call initializeFlavors once in the app as shown in the flavor guide. with no flavors or onSelect prop, choosing an entry sets the global flavor store. no built-in collection is promised to package consumers.
normal mode includes a trigger and Popover. openFlavorPicker() opens shared picker visibility, and flavorPickerVisible.set(false) closes it. mount one global picker so shared visibility doesn’t open several copies.
controlled collection
when flavors is supplied, the component calls onSelect(definition) instead of selecting globally. provide selected to reflect the current name and update it in your handler. supplying definitions doesn’t register them. an onSelect without explicit flavors also takes ownership of selection.
API reference
FlavorPicker
title- Default:
'flavors'the picker heading.
description- Default:
'pick your favorite'supporting text beneath the heading.
pickerOnly- Default:
falserenders picker content without the trigger and Popover.
flavors-
explicit local collection, without registering its definitions.
onSelect-
takes ownership of selection with the chosen definition.
selected-
the currently selected flavor name for a controlled picker.
ButtonIcon-
component visual for the trigger.
buttonIconSrc-
trigger image when ButtonIcon is absent.
class- Default:
''extra classes on the picker root.
style-
inline styles on the picker root.