Typography
Definition Lists Element
Style definition list elements (dl, dt, dd) with configurable margin, font weight, and spacing using the useDlElement, useDtElement, and useDdElement composables.
Part of the Global Preset:
useDlElement, useDtElement, and useDdElement are included in the Global Preset (useGlobalPreset) and you can configure them through the preset's dl, dt, and dd options. For most projects, applying them via the preset is the recommended approach.Overview
The definition list composables style the dl, dt, and dd elements for displaying term-description pairs. They control margin, font weight, and spacing to create readable, well-structured definition lists.
useDlElement
function useDlElement(
s: Styleframe,
options?: WithThemes<DlElementConfig>
): DlElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useDlElement } from '@styleframe/theme';
const s = styleframe();
const { dlMarginBottom } = useDlElement(s);
export default s;
styleframe/index.css
:root {
--dl--margin-bottom: var(--spacing);
}
dl {
margin-bottom: var(--dl--margin-bottom);
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
marginBottom | "@spacing" | --dl--margin-bottom | dlMarginBottom |
useDtElement
function useDtElement(
s: Styleframe,
options?: WithThemes<DtElementConfig>
): DtElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useDtElement } from '@styleframe/theme';
const s = styleframe();
const { dtFontWeight } = useDtElement(s);
export default s;
styleframe/index.css
:root {
--dt--font-weight: var(--font-weight--bold);
}
dt {
font-weight: var(--dt--font-weight);
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
fontWeight | "@font-weight.bold" | --dt--font-weight | dtFontWeight |
useDdElement
function useDdElement(
s: Styleframe,
options?: WithThemes<DdElementConfig>
): DdElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useDdElement } from '@styleframe/theme';
const s = styleframe();
const { ddMarginBottom, ddMarginLeft } = useDdElement(s);
export default s;
styleframe/index.css
:root {
--dd--margin-bottom: var(--spacing--xs);
--dd--margin-left: 0;
}
dd {
margin-bottom: var(--dd--margin-bottom);
margin-left: var(--dd--margin-left);
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
marginBottom | "@spacing.xs" | --dd--margin-bottom | ddMarginBottom |
marginLeft | "0" | --dd--margin-left | ddMarginLeft |
Custom Values
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useDlElement, useDtElement, useDdElement } from '@styleframe/theme';
const s = styleframe();
const { dlMarginBottom } = useDlElement(s, {
marginBottom: '@spacing.lg',
});
const { dtFontWeight } = useDtElement(s, {
fontWeight: '@font-weight.semibold',
});
const { ddMarginBottom, ddMarginLeft } = useDdElement(s, {
marginBottom: '@spacing.sm',
marginLeft: '@spacing.md',
});
export default s;
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useGlobalPreset } from '@styleframe/theme';
const s = styleframe();
const { dl, dt, dd } = useGlobalPreset(s, {
dl: {
marginBottom: '@spacing.lg',
},
dt: {
fontWeight: '@font-weight.semibold',
},
dd: {
marginBottom: '@spacing.sm',
marginLeft: '@spacing.md',
},
});
export default s;
styleframe/index.css
:root {
--dl--margin-bottom: var(--spacing--lg);
--dt--font-weight: var(--font-weight--semibold);
--dd--margin-bottom: var(--spacing--sm);
--dd--margin-left: var(--spacing--md);
}
dl {
margin-bottom: var(--dl--margin-bottom);
}
dt {
font-weight: var(--dt--font-weight);
}
dd {
margin-bottom: var(--dd--margin-bottom);
margin-left: var(--dd--margin-left);
}
Best Practices
- Use all three together: The
dl,dt, andddcomposables are designed to work as a set for consistent definition list styling. - Keep terms bold: The default bold font weight for
dtelements establishes clear visual hierarchy between terms and descriptions. - Reset the left margin: The default
marginLeft: "0"removes the browser default indentation onddelements for a cleaner layout.