Lists
The list feature lets you create ordered (numbered) and unordered (bulleted) lists. This allows for better structuring and presenting specific content such as enumerating elements, creating tables of content or to-do lists.
Lists are useful when you want to emphasize selected information, highlight a series of steps, enumerate items of a collection. They draw the reader’s attention and, just like block quotes or indentation, give the text a structure and breathing room. They help visually separate passages for a better reading experience and make skimming for information easier.
You may find additional interesting details and examples in the Lists in CKEditor 5 blog post after reading this guide.
This feature is enabled by default in all predefined builds.
# Ordered and unordered lists
An unordered (bulleted) list can represent items where the order is not important, for example, a list of ingredients required for preparing a dish or a drink.
An ordered (numbered) list can be used if the order of the items matters, for example, when creating an instruction. Here, the sequence of steps that must be done is important.
# Demo
Use the editor below to see the CKEditor 5 list feature in action. Toolbar buttons can be used to insert both ordered and unordered lists .
A Markdown code provided by the autoformatting feature can also be utilized:
- Start a line with
*
or-
followed by a space for a bulleted list. - Start a line with
1.
or1)
followed by a space for a numbered list.
Ingredients
Ingredients required for making a coffee:
- 15g ground coffee
- water
- milk (optional)
Instructions
How to prepare a cup of coffee:
- Gather the ingredients.
- Put 15g of ground coffee in the cup.
- Boil 200ml of water.
- Pour the water into the cup.
- Optional: Add milk.
# List properties
Beside the basic functionality of creating the ordered and unordered lists, CKEditor 5 offers additional formatting tools that allow controlling the lists. Features such as more styles for list markers, setting the start index or reversing the list order can be enabled separately or all together. Check out the individual demos below or see all list properties working together in the full-featured editor example.
The list properties feature is enabled by default in the document editor build only. See the installation section to learn how to enable it in your editor.
# List styles
The list style feature introduces some more styles for the list item markers. When enabled, it adds 3 styles for unordered lists and 6 styles for ordered lists to choose from. The user will be able to set or change the list style via the dropdown that opens when you click the arrow next to the appropriate list button in the toolbar.
# Demo
In the editor below use the ordered or unordered list dropdown to choose the desired marker type for each list.
Modern manned spacecraft
- Soyuz (Soviet/Russian)
- Early stage (all retired)
- 7K-OK
- 7KT-OK
- 7K-T
- 7K-TM
- Soyuz T (retired)
- Soyuz TM (retired)
- Soyuz TMA (retired)
- Soyuz TMA-M (retired)
- Soyuz MS
- STS orbiter (American; all retired)
- Columbia
- Challenger
- Discovery
- Atlantis
- Endeavour
- SpaceX Crew Dragon (American)
- Shenzhou (Chinese)
# List start index
The list start index feature allows the user to choose the starting point of an ordered list. By default, this would be 1
(or A
, or I
— see the list styles section), but in certain situations it may be desired to start a list with some other digit or letter.
When this feature is enabled, an additional dropdown option is available in the ordered list toolbar button. Thanks to it, the user may set or change the starting marker.
# Demo
In the editor below, notice how the ordering is continued in the second list. You can go to the first item of the last list and use the ordered list dropdown input field to set the start index to achieve continuous numbering of spaceships.
A list of human spacecraft
Soviet and Russian spaceships:
- Vostok
- Voskhod
- Soyuz
- Progress (cargo)
American spaceships:
- Mercury
- Gemini
- Apollo
- space shuttle
- Dragon
Chinese spaceships:
- Shenzhou
- Tianzhou (cargo)
# Reversed list
The reversed list feature lets the user reverse the numbering order of a list, changing it from ascending to descending. This is especially useful in countdowns and things-to-do lists that need to reproduce steps in a reversed order (for example, in a disassembling instruction in an owners manual).
When this feature is enabled, an additional dropdown switch is available in the ordered list toolbar button. Thanks to it, the user may easily reverse the order of a list with a single click.
# Demo
Click the second list and use the ordered list dropdown switch to choose whether it should be reversed.
Replacing the screen of your Nintendo Game Boy
Disassembling the console
- Remove the game cartridge from the slot. Open the battery compartment and remove batteries.
- Remove the six triwing (Y-type screwdriver needed) screws located at the top and middle of the back case and inside the battery compartment.
- Separate the front and back case halves. Be extra careful not to pull the cable ribbon that connects both parts. Detach the ribbon carefully.
- Remove the ten Philips screws holding the mainboard to the front case. Carefully take the mainboard out of the case.
- Detach three plastic clips on the backside of the board and remove two Philips screws on the front, below the screen.
- Desolder the display connectors from the mainboard.
Reassembling the console
- Solder the display connector to the mainboard.
- Fasten the two screws below the screen and reattach three plastic clips on the backside of the mainboard
- Put the mainboard carefully inside the front case and screw in ten Philips screws holding the mainboard.
- Reattach the main cable ribbon to the back casing and put the case halves together.
- Fasten the six triwing screws inside the battery compartment and on the back of the case.
- Reload three AA-size batteries, close the compartment cover and insert your favorite game cartridge to play!
You can see all the list properties together in action in the Full-featured editor and Document editor examples.
# List indentation
Refer to the Indenting lists section of the Block indentation feature guide.
# Related features
These features also provide similar functionality:
- To-do lists – Create a list of interactive checkboxes with labels.
- Block indentation – Set indentation for text blocks such as paragraphs or headings and lists.
- Autoformatting – Format the text on the go with Markdown code.
# Installation
The base list feature is enabled by default in all predefined editor builds. The installation instructions are for developers interested in building their own, custom editor.
To add this feature to your editor, install the @ckeditor/ckeditor5-list
package:
npm install --save @ckeditor/ckeditor5-list
Then add the List
plugin to your plugin list and the toolbar configuration:
import List from '@ckeditor/ckeditor5-list/src/list';
ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [ List, ... ],
toolbar: [ 'bulletedList', 'numberedList', ... ]
} )
.then( ... )
.catch( ... );
# List properties
The list properties feature is enabled by default in the document editor build only.
To enable the list properties feature, install the @ckeditor/ckeditor5-list
package:
npm install --save @ckeditor/ckeditor5-list
Then add the ListProperties
plugin to your plugin list and configure the toolbar. To enable selected sub-features of the list properties, you need to add their configuration to your editor (set true
for each feature you want to enable):
import ListProperties from '@ckeditor/ckeditor5-list/src/listproperties';
ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [ ListProperties, ... ],
toolbar: [ 'bulletedList', 'numberedList', ... ],
list: {
properties: {
styles: true,
startIndex: true,
reversed: true
}
}
} )
.then( ... )
.catch( ... );
Read more about installing plugins.
The ListProperties
feature overrides UI button implementations from the ListUI
.
# Common API
The List
plugin registers:
- The
'numberedList'
command. - The
'bulletedList'
command. - The
'indentList'
command. - The
'outdentList'
command. - The
'numberedList'
UI button. - The
'bulletedList'
UI button.
The ListProperties
plugin registers:
-
The
listStyle
command that accepts thetype
of the list style to set. If not set, is uses the default marker (usually decimal).editor.execute( 'listStyle', { type: 'lower-roman' } );
The available types are:
- For bulleted lists:
'disc'
,'circle'
and'square'
. - For numbered lists:
'decimal'
,'decimal-leading-zero'
,'lower-roman'
,'upper-roman'
,'lower-latin'
and'upper-latin'
.
- For bulleted lists:
-
The
listStart
command which is a Number and defaults to1
(meaning a list starts with1
). If enabled, it accepts a numerical value for thestart
attribute.editor.execute( 'listStart', { startIndex: 3 } );
-
The
listReversed
command which is a Boolean and defaults tofalse
(meaning the list order is ascending).editor.execute( 'listReversed', { reversed: 'true' } );
-
The
numberedList
UI split button that overrides the UI button registered by theList
plugin. -
The
bulletedList
UI split button that overrides the UI button registered by theList
plugin.
# Contribute
The source code of the feature is available on GitHub in https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-list.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.