Skip to content

Composables ​

Forty-three composables and two directives. Every signature on these pages was read off the source file, not the older documentation.

They sit on forty pages: three of them — useShortcutRegistry, useShortcutCheatSheet and useTourController — are documented beside the sibling they share a module with.

Each page follows the same shape: what it is, the import, the real signature, a table of everything it returns, a complete example, the behavior worth knowing, and where to go next. Where a composable has a visible effect, the example on its page is running.

Core ​

Configuration, the theme engine and language.

ComposableWhat it does
useConfigThe store that owns the whole SmartAdminConfig, persisted.
usePageConfigPer-page overrides, without writing to the store.
useThemeBrand colors, their generated ramps, and dark mode.
useThemeProviderThe tenant palette at startup, cache first.
useTypographyThe type scale, as three presets.
useDensityThe spacing preset.
useFontsLoading web fonts on demand.
useChartThemeChart colors, re-resolved when the theme changes.
useLocaleSwitching language, and the nine shipped locales.
useDirectiondir and lang on the document.

Forms and data ​

The schema engine and everything built on it.

ComposableWhat it does
useSchemaOne field list, reshaped into form fields, columns, groups and Zod.
useFormSurfaceWhat kind of container a form is rendering inside.
useCrudTyped list, create, update and delete with pagination and toasts.
useRouteRecordA detail page's record, reloaded when the id changes, with a not-found state.
useFormDraftAuto-saving a form in progress.
useFormDirtyWarning before unsaved changes are lost.
useSaEditorA Tiptap editor with the template's extensions.

Auth and errors ​

ComposableWhat it does
useAuthLogin, logout, session refresh, and the boot-time rehydrate.
usePermissionscan and cannot, over CASL.
useNavPermissionThe menu's own gates, which treat guests differently.
useApiErrorWhat each HTTP status looks like to the reader.

Productivity ​

The command palette, shortcuts, the tour and the shell's own drawers.

ComposableWhat it does
useCommandRegistryEvery command the palette can run.
useCommandPaletteOpening and closing it.
useShortcutsKey bindings, and the registry behind the cheat sheet.
usePageShortcutsThe same, scoped to one page.
useTourThe guided tour.
usePinnedPagesThe reader's own shortlist of pages.
useResponsivePreviewThe device preview's state and catalog.
useCustomizerThe theme drawer's open state.

Infrastructure ​

ComposableWhat it does
useConfirmawait confirm(...), from anywhere.
useFileUploadSelecting, validating and uploading files.
useExportCSV, Excel and PDF, lazy-loaded.
useNotificationsThe store behind the navbar bell.
useRealtimeNotificationsAn optional live feed.
useActivityLogWriting audit entries.
useConnectivityOnline, offline, and just reconnected.
useSubscriptionPlans, billing cycle and usage.
useAvailableHeightA real height for a pane that scrolls inside itself.
useLayoutWhich of the six shells renders.
useResponsiveLayoutWhat "mobile" means, and the drawer.

Directives ​

DirectiveWhat it does
v-copyClick an element to copy it.
v-permissionHide an element the user may not act on.

Both are registered globally in a project built from the template.

Conventions ​

  • Imports are absolute, through the template's aliases:

    ts
    import { useConfig } from '@core/config/useConfig'
    import { useConfirm } from '@shared/composables/useConfirm'
    import { useLayout } from '@/layouts/useLayout'
  • A lot of these are singletons. Module-scope state, not per-caller state, so the navbar and a widget three routes away read the same value. Each page says so where it matters.

  • readonly means write through the functions beside it. A returned ref wrapped in readonly has setters alongside it; that is the supported path.

  • Several persist to localStorage, all under an sa- prefix: sa-config, sa-color-mode, sa-tenant-theme, sa-notifications, sa-pinned, sa-tours, sa-recent-commands, and one sa-draft:{key} per form.

  • Anything that touches the DOM checks for it first, so a setter called before mount is a no-op rather than a crash. The two Pinia stores are the exception: they name localStorage when their module is evaluated, so they are not safe to import in a server render.

Where to go next ​