Lists
note
Lists are rendered with an internal renderer. See ​Rendering page. The content model of lists is ​block, see ​Element Models.
tip
Lists marker rendering logic has been extracted to ​@jsamr/react-native-li and ​@jsamr/counter-style libraries for convinience! Fell free to use these outside of a ​RenderHTML component.
List Style Type#
List elements support ​list-style-type CSS property, which defines how the marker pseudo-element of a list item should be rendered. In CSS terminology, a marker is a pseudo-element situated before elements with a ​display property set to list-item. See CSS Lists and Counters Module Level 3 for a standard reference and ​DefaultSupportedListStyleType for a list of types supported by this library.
Ordered Lists#
Ordered lists ​<ol> elements support by default 6 list style types:
decimal: 1, 2, 3 ... (the default)lower-alpha: a, b, c ...upper-alpha: A, B, C ...lower-greek: α, β, γ ...lower-roman: i, ii, iii ...upper-roman: I, II, III ...
- JSX Source
- HTML Snippet
- TRT Snapshot
tip
You can actually very easily plug-in one of the dozens presets from ​@jsamr/counter-style, including Persian, Arabic, Hebrew, Thai, Katana... see the below chapter.
Unordered Lists#
Unordered lists ​<ul> elements support by default 5 list style types:
disc: "•" (the default)square: "■"circle: "○"disclosure-open: "▼"disclosure-closed: "▶"
note
Those markers are not rendered with UTF-8 characters, which might have a significant variety of shapes and sizes depending on fonts. Instead, geometric shapes are rendered.
- JSX Source
- HTML Snippet
- TRT Snapshot
Defining and Customizing Markers Pseudo-Elements#
Using a Preset from @jsamr/counter-style#
The ​customListStyleSpecs prop allows you to create as many list type styles as you wish. Combined with the power of ​@jsamr/counter-style, you can plug-in one of the dozens of presets with a one-liner! See below example with the Thai preset:
- JSX Source
- HTML Snippet
- TRT Snapshot
Creating a Counter Style#
​@jsamr/counter-style allows you to create any counter style, translating strictly the ​@counter-style at-rule API defined in CSS Counter Styles Level 3 in a JavaScript API. In the below example, we are going to create an alphabetic counter style for the Russian alphabet:
- JSX Source
- HTML Snippet
- TRT Snapshot
Experimental RTL Mode#
Thanks to ​renderersProps prop, you can enable experimental RTL support for lists (see ​RenderersProps.ol and ​RenderersProps.ul).
note
Example: Unordered Lists#
- JSX Source
- HTML Snippet
- TRT Snapshot
Example: Ordered Lists Arabic#
- JSX Source
- HTML Snippet
- TRT Snapshot