Composables
Lists Element
Style ordered and unordered list elements with configurable margin and padding using the useOlElement and useUlElement composables.
Overview
The list composables style ol and ul elements with configurable bottom margin and left padding. Both composables automatically reset the bottom margin of nested lists to prevent double spacing.
useOlElement
function useOlElement(
s: Styleframe,
options?: WithThemes<OlElementConfig>
): OlElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useOlElement } from '@styleframe/theme';
const s = styleframe();
const { olMarginBottom, olPaddingLeft } = useOlElement(s);
export default s;
styleframe/index.css
:root {
--ol--margin-bottom: var(--spacing);
--ol--padding-left: var(--spacing--lg);
}
ol {
margin-bottom: var(--ol--margin-bottom);
padding-left: var(--ol--padding-left);
}
ol ol, ol ul {
margin-bottom: 0;
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
marginBottom | "@spacing" | --ol--margin-bottom | olMarginBottom |
paddingLeft | "@spacing.lg" | --ol--padding-left | olPaddingLeft |
useUlElement
function useUlElement(
s: Styleframe,
options?: WithThemes<UlElementConfig>
): UlElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useUlElement } from '@styleframe/theme';
const s = styleframe();
const { ulMarginBottom, ulPaddingLeft } = useUlElement(s);
export default s;
styleframe/index.css
:root {
--ul--margin-bottom: var(--spacing);
--ul--padding-left: var(--spacing--lg);
}
ul {
margin-bottom: var(--ul--margin-bottom);
padding-left: var(--ul--padding-left);
}
ul ol, ul ul {
margin-bottom: 0;
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
marginBottom | "@spacing" | --ul--margin-bottom | ulMarginBottom |
paddingLeft | "@spacing.lg" | --ul--padding-left | ulPaddingLeft |
Custom Values
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useOlElement, useUlElement } from '@styleframe/theme';
const s = styleframe();
const { olMarginBottom } = useOlElement(s, {
marginBottom: '@spacing.lg',
paddingLeft: '@spacing.xl',
});
const { ulMarginBottom } = useUlElement(s, {
marginBottom: '@spacing.lg',
paddingLeft: '@spacing.xl',
});
export default s;
styleframe/index.css
:root {
--ol--margin-bottom: var(--spacing--lg);
--ol--padding-left: var(--spacing--xl);
--ul--margin-bottom: var(--spacing--lg);
--ul--padding-left: var(--spacing--xl);
}
ol {
margin-bottom: var(--ol--margin-bottom);
padding-left: var(--ol--padding-left);
}
ol ol, ol ul {
margin-bottom: 0;
}
ul {
margin-bottom: var(--ul--margin-bottom);
padding-left: var(--ul--padding-left);
}
ul ol, ul ul {
margin-bottom: 0;
}
Best Practices
- Use both together: Apply
useOlElementanduseUlElementtogether with matching values for consistent list styling. - Rely on nested list resets: Both composables automatically set
margin-bottom: 0on nested lists (ol ol,ol ul,ul ol,ul ul), preventing double spacing in multi-level lists. - Use spacing tokens: Reference
@spacingand@spacing.lgfor margin and padding to stay consistent with your layout system.