Lists
Style modifiers for default HTML ordered <ol>
, unordered <ul>
and definition <dl>
lists.
Ordered and unordered lists (anchor)
Unstyled (anchor)
<ol class="ol-none">
- Item 1
- Item 2
- Item 3
- Item 4
<ul class="ul-none">
- Item 1
- Item 2
- Item 3
- Item 4
Inline lists (anchor)
<ol class="ol-inline">
- Item 1
- Item 2
- Item 3
- Item 4
<ul class="ul-inline">
- Item 1
- Item 2
- Item 3
- Item 4
<ul class="ul-inline" style="--gap: 2rem;">
- Item 1
- Item 2
- Item 3
- Item 4
Comma list (anchor)
<ul class="list-comma">
- Item 1
- Item 2
- Item 3
- Item 4
Dividers (anchor)
<ul class="list-divider">
<ul class="list-divider" style="--divider: '/';">
<ul class="list-divider" style="--divider: '>';">
The divider spacing uses padding values and can also be adjusted inline:
<ul class="list-divider" style="--divider-px: 1rem;">
Definition lists (anchor)
Bold term (anchor)
<dl class="dt-bold">
- Term 1
- Description 1
- Description 2
- Term 2
- Description 1
- Description 2
Unstyled (anchor)
<dl class="dl-none">
- Term 1
- Description 1
- Description 2
- Term 2
- Description 1
- Description 2
Inline lists (anchor)
Meta list (anchor)
<dl class="dl-meta">
<dl class="dl-meta dt-bold">
<dl class="dl-meta" style="--dl-meta-gap: 1.5rem;">
<dl class="dl-meta dt-bold" style="--dt-colon: '';">
Comma lists (anchor)
<dl class="dl-comma">
- Categories
- Styles
- Utilities
- Lists
- Tags
- CSS
- SCSS
- HTML
<dl class="dl-comma-inline">
- Tags
- Styles
- Utilities
- Lists
- CSS
- SCSS
- HTML
Using the module (anchor)
Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.
@use "stylemods/scss" as *;
@include lists-css;
See the using modules page for more information including how to compile the modules in cascade layers and include and reuse them in multiple source files.
Using the framework (anchor)
Using the recommended custom setup enable the styles in an overrides document:
@use "stylemods/scss/configuration" as *;
$enable-lists: true;
Include the overrides and the framework styles with your custom document for compiling the framework:
@use "overrides";
@use "stylemods/scss/stylemods";
See using the framework for more information including how the styles can also be compiled within cascade layers.
Source code (anchor)
lists.scss
// ----------------------------------------------------------
// Lists
// ----------------------------------------------------------
@mixin list-reset {
list-style-type: "";
padding-inline-start: 0;
}
@mixin lists-css {
// Ordered <ol> and unordered <ul>
:where(.ul-none, .ol-none, .ul-inline, .ol-inline, .list-comma, .list-divider) {
@include list-reset;
}
:where(.ul-inline, .ol-inline, .list-comma, .list-divider) {
display: flex;
flex-wrap: wrap;
}
:where(.ul-inline, .ol-inline) {
column-gap: var(--gap, .75rem);
}
:where(.list-comma) {
column-gap: var(--gap, .3rem);
}
.list-comma *:not(:last-child):after {
content: ",";
}
.list-divider *:not(:first-child) {
padding-inline-start: var(--divider-px, .5rem);
}
.list-divider *:not(:last-child):after {
content: var(--divider, "|");
padding-inline-start: var(--divider-px, .5rem);
}
:where(.dl-none, .dl-meta, .dl-comma, .dl-comma-inline) dd {
margin-inline-start: 0;
}
// Definition <dl>
.dl-meta {
display: grid;
grid-template-columns: minmax(0, auto) minmax(0, 1fr);
column-gap: var(--dl-meta-gap, .75rem);
}
:where(.dl-comma, .dl-comma-inline) {
display: flex;
flex-wrap: wrap;
column-gap: var(--gap, 0.3rem);
}
.dl-comma-inline dt {
margin-inline-end: var(--dt-me, 0.15rem);
}
:where(.dl-meta, .dl-comma-inline) dt:after {
font-weight: 400;
content: var(--dt-colon, ":");
}
.dl-comma dt {
inline-size: 100%;
}
:where(.dl-comma) dt:not(:first-child) {
margin-block-start: var(--dt-mt, 0.25rem);
}
:where(.dl-comma, .dl-comma-inline) dd:not(:last-child):after {
content: var(--content, ",");
}
:where(.dl-comma, .dl-comma-inline) dd:not(:last-child):has(+ dt):after {
content: "";
}
} // end lists-css