Elements Overview
Element composables apply sensible default styles to native HTML elements — body, headings, paragraphs, links, lists, code blocks, and more. Each composable creates CSS custom properties that you can override per-theme, giving you a fully customizable foundation layer without writing raw CSS.
Why Use Element Composables?
Element composables help you:
- Establish consistent base styles: Apply typographic and spacing defaults to every HTML element in one place.
- Enable theme-aware overrides: Each composable supports the
WithThemes<Config>pattern, so dark mode or brand themes can override any property. - Customize with CSS variables: Every style property is backed by a CSS custom property, making runtime overrides trivial.
- Avoid CSS resets from scratch: Get opinionated but sensible defaults for all common HTML elements out of the box.
- Compose incrementally: Use individual composables for fine-grained control, or
useGlobalPresetto apply everything at once.
Quick Start
The fastest way to style all HTML elements is with useGlobalPreset:
import { styleframe } from 'styleframe';
import { useGlobalPreset } from '@styleframe/theme';
const s = styleframe();
const { body, heading, link } = useGlobalPreset(s);
export default s;
This single call registers base styles for all HTML elements, focus outlines, and text selection — with sensible defaults that reference your design tokens.
Learn more about the Global Preset →
Composables
Text Content
Style the core text elements that make up the majority of page content.
Available composables:
useBodyElement(): Set the base font family, size, line height, color, and background for thebodyelementuseHeadingElement(): Configure typography forh1throughh6with per-level font sizesuseParagraphElement(): Control paragraph spacing with top and bottom marginsuseLinkElement(): Define link colors and text decoration, including hover states
import { styleframe } from 'styleframe';
import { useBodyElement, useHeadingElement, useLinkElement } from '@styleframe/theme';
const s = styleframe();
const { bodyColor, bodyBackground } = useBodyElement(s);
const { headingH1FontSize } = useHeadingElement(s);
const { linkColor, linkHoverColor } = useLinkElement(s);
export default s;
Learn more about Body → · Headings → · Paragraphs → · Links →
Lists
Style ordered, unordered, and definition lists with consistent spacing.
Available composables:
useOlElement(): Configure ordered list margin and paddinguseUlElement(): Configure unordered list margin and paddinguseDlElement(): Set definition list bottom marginuseDtElement(): Control definition term font weightuseDdElement(): Set definition description margins
import { styleframe } from 'styleframe';
import { useOlElement, useUlElement } from '@styleframe/theme';
const s = styleframe();
const { olMarginBottom, olPaddingLeft } = useOlElement(s);
const { ulMarginBottom, ulPaddingLeft } = useUlElement(s);
export default s;
Learn more about Lists → · Definition Lists →
Code & Inline Text
Style code blocks, keyboard input, sample output, abbreviations, and highlighted text.
Available composables:
useCodeElement(): Set font family and size for inlinecodeandsampelementsusePreElement(): Configure preformatted text blocks with scroll overflowuseKbdElement(): Style keyboard input elements with background, color, and paddinguseSampElement(): Set the font family for sample output elementsuseAbbrElement(): Configure abbreviation cursor and text decorationuseMarkElement(): Style highlighted text with background color and padding
import { styleframe } from 'styleframe';
import { useCodeElement, useKbdElement } from '@styleframe/theme';
const s = styleframe();
const { codeFontFamily, codeFontSize } = useCodeElement(s);
const { kbdBackground, kbdColor } = useKbdElement(s);
export default s;
Learn more about Code → · Kbd → · Mark → · Abbreviation → · Sample Output →
Structural Elements
Style dividers, table captions, addresses, and other structural HTML elements.
Available composables:
useHrElement(): Configure horizontal rule border style, color, and marginuseCaptionElement(): Set table caption color, padding, and text alignmentuseAddressElement(): Control address element margins and font style
import { styleframe } from 'styleframe';
import { useHrElement, useCaptionElement } from '@styleframe/theme';
const s = styleframe();
const { hrBorderColor, hrMargin } = useHrElement(s);
const { captionColor, captionTextAlign } = useCaptionElement(s);
export default s;
Learn more about Horizontal Rule → · Caption → · Address →
Global States
Apply consistent focus and selection styles across all elements.
Available composables:
useFocusState(): Define the:focus-visibleoutline color, width, style, and offsetuseSelectionState(): Set::selectionbackground and text color
import { styleframe } from 'styleframe';
import { useFocusState, useSelectionState } from '@styleframe/theme';
const s = styleframe();
const { focusOutlineColor } = useFocusState(s);
const { selectionBackground, selectionColor } = useSelectionState(s);
export default s;
Learn more about Focus → · Selection →
Simple Elements
These composables apply fixed styles with no configuration options.
Available composables:
useImgElement(): Alignsimgandsvgelements tovertical-align: middleuseIframeElement(): Removes the default border fromiframeelementsuseOutputElement(): Setsoutputelements todisplay: inline-blockuseLegendElement(): Styleslegendelements for proper form layoutuseSummaryElement(): Setscursor: pointeronsummaryelements
Learn more about Image → · Iframe → · Output → · Legend → · Summary →
Element Reference
| Category | Composable | HTML Element | CSS Variables |
|---|---|---|---|
| Text | useBodyElement | body | 5 |
useHeadingElement | h1–h6 | 10 | |
useParagraphElement | p | 2 | |
useLinkElement | a | 4 | |
| Lists | useOlElement | ol | 2 |
useUlElement | ul | 2 | |
useDlElement | dl | 1 | |
useDtElement | dt | 1 | |
useDdElement | dd | 2 | |
| Code | useCodeElement | code, samp | 2 |
usePreElement | pre | 3 | |
useKbdElement | kbd | 7 | |
useSampElement | samp | 1 | |
| Inline | useAbbrElement | abbr[title] | 2 |
useMarkElement | mark | 6 | |
| Structural | useHrElement | hr | 4 |
useCaptionElement | caption | 6 | |
useAddressElement | address | 1 | |
| States | useFocusState | :focus-visible | 4 |
useSelectionState | ::selection | 2 | |
| Simple | useImgElement | img, svg | 0 |
useIframeElement | iframe | 0 | |
useOutputElement | output | 0 | |
useLegendElement | legend | 0 | |
useSummaryElement | summary | 0 |
Best Practices
- Use
useGlobalPresetfor new projects: It applies all element styles in a single call with sensible defaults - Disable elements you don't need: Pass
falseto any element in the preset config to skip it entirely - Reference design tokens: Element defaults use
@references like@color.primaryand@spacing, so they stay in sync with your token system - Override per-theme: Use the
themesoption to customize element styles for dark mode or other themes without duplicating config - Compose individually when needed: For fine-grained control, use individual composables instead of the preset