Skip Navigation

List

Lists are vertical groupings of related content. Lists come either ordered or unordered.

Basic Usage

By default List uses an unorganized markup <ul>.

  • Reptiles
    • Snakes
      • Python
      • Boa Constrictor
      • Corn Snake
    • Lizards
      • Geckos
      • Iguanas
      • Chameleons
  • Birds
    • Parrots
      • African Grey
      • Cockatiel
      • Budgerigar
    • Birds of Prey
      • Eagles
      • Hawks
      • Falcons
import React from 'react';
import { List, ListItem } from 'react-magma-dom';
export function Example() {
return (
<List>
<ListItem>
Reptiles
<List>
<ListItem>
Snakes
<List>
<ListItem>Python</ListItem>
<ListItem>Boa Constrictor</ListItem>
<ListItem>Corn Snake</ListItem>
</List>
</ListItem>
<ListItem>
Lizards
<List>
<ListItem>Geckos</ListItem>
<ListItem>Iguanas</ListItem>
<ListItem>Chameleons</ListItem>
</List>
</ListItem>
</List>
</ListItem>
<ListItem>
Birds
<List>
<ListItem>
Parrots
<List>
<ListItem>African Grey</ListItem>
<ListItem>Cockatiel</ListItem>
<ListItem>Budgerigar</ListItem>
</List>
</ListItem>
<ListItem>
Birds of Prey
<List>
<ListItem>Eagles</ListItem>
<ListItem>Hawks</ListItem>
<ListItem>Falcons</ListItem>
</List>
</ListItem>
</List>
</ListItem>
</List>
);
}

Ordered List

Another method of List is the ordered list <ol>. There are several methods of showing ordered list items.

  • The hasStart prop permits the user to define a specific letter or number from which the list items descend.
  • The isReversed prop changes the order from ascending to descending numbers or letters.
  • The listType prop allows for changing the bulleted items from a number to lowercase letters, uppercase letters, lowercase Roman numerals, or uppercase Roman numerals.
  1. Fruits
    1. Apples
    2. Bananas
    3. Oranges
  2. Vegetables
    1. Leafy greens
      1. Spinach
      2. Kale
    2. Root vegetables
      1. Carrots
      2. Potatoes
  3. Dairy
    1. Milk
    2. Cheese
import React from 'react';
import { List, ListItem, olListType } from 'react-magma-dom';
export function Example() {
return (
<List
isOrdered
listType={olListType.uppercaseRoman}
hasStart="3"
isReversed
>
<ListItem>
Fruits
<List isOrdered listType={olListType.lowercaseRoman}>
<ListItem>Apples</ListItem>
<ListItem>Bananas</ListItem>
<ListItem>Oranges</ListItem>
</List>
</ListItem>
<ListItem>
Vegetables
<List isOrdered listType={olListType.lowercaseRoman}>
<ListItem>
Leafy greens
<List isOrdered listType={olListType.lowercase}>
<ListItem>Spinach</ListItem>
<ListItem>Kale</ListItem>
</List>
</ListItem>
<ListItem>
Root vegetables
<List isOrdered listType={olListType.lowercase}>
<ListItem>Carrots</ListItem>
<ListItem>Potatoes</ListItem>
</List>
</ListItem>
</List>
</ListItem>
<ListItem>
Dairy
<List isOrdered listType={olListType.lowercaseRoman}>
<ListItem>Milk</ListItem>
<ListItem>Cheese</ListItem>
</List>
</ListItem>
</List>
);
}

Description

The description prop is a boolean which changes a nested list item into a styled paragraph.

This prop has been deprecated. Use DefinitionList instead.

  • Mammals
    • Dogs
      • German Shepherd

        Courageous, energetic, loyal

      • Labrador Retriever

        Friendly, outgoing, high-spirited

      • American Bully

        Strong, athletic, affectionate

    • Cats
import React from 'react';
import { List, ListItem } from 'react-magma-dom';
export function Example() {
return (
<List>
<ListItem>
Mammals
<List>
<ListItem>
Dogs
<List>
<ListItem>
German Shepherd
<ListItem description>Courageous, energetic, loyal</ListItem>
</ListItem>
<ListItem>
Labrador Retriever
<ListItem description>
Friendly, outgoing, high-spirited
</ListItem>
</ListItem>
<ListItem>
American Bully
<ListItem description>Strong, athletic, affectionate</ListItem>
</ListItem>
</List>
</ListItem>
<ListItem>Cats</ListItem>
</List>
</ListItem>
</List>
);
}

Icon List

An Icon List allows the user to use Magma Icons in place of bulleted or numeric characters.

  • iconSize will toggle between three size states with medium being default.
  • iconAlign changes the vertical alignment.
  • iconBackground and iconColor change both the background and icon colors.

Icon sizes

  • Inbox
  • Drafts
  • Trash

  • Inbox
  • Drafts
  • Trash

  • Inbox
  • Drafts
  • Trash
import React from 'react';
import { List, ListItem, IconSizes } from 'react-magma-dom';
import { InboxIcon, DraftsIcon, DeleteIcon } from 'react-magma-icons';
export function Example() {
return (
<>
<List iconSize={IconSizes.small} spacingStyle="spacing02">
<ListItem icon={<InboxIcon />}>Inbox</ListItem>
<ListItem icon={<DraftsIcon />}>Drafts</ListItem>
<ListItem icon={<DeleteIcon />}>Trash</ListItem>
</List>
<br />
<List spacingStyle="spacing02">
<ListItem icon={<InboxIcon />}>Inbox</ListItem>
<ListItem icon={<DraftsIcon />}>Drafts</ListItem>
<ListItem icon={<DeleteIcon />}>Trash</ListItem>
</List>
<br />
<List iconSize={IconSizes.large} spacingStyle="spacing02">
<ListItem icon={<InboxIcon />}>Inbox</ListItem>
<ListItem icon={<DraftsIcon />}>Drafts</ListItem>
<ListItem icon={<DeleteIcon />}>Trash</ListItem>
</List>
</>
);
}

Icon Alignment

  • Icon List content
  • Icon List content
  • Icon List content

  • Icon List content
  • Icon List content
  • Icon List content
import React from 'react';
import { List, ListItem, IconAlignment } from 'react-magma-dom';
import { EmailIcon } from 'react-magma-icons';
export function Example() {
return (
<>
<List iconAlign={IconAlignment.top} spacingStyle="spacing02">
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
</List>
<br />
<List iconAlign={IconAlignment.center} spacingStyle="spacing02">
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
<ListItem icon={<EmailIcon />}>Icon List content</ListItem>
</List>
</>
);
}

Icon colors

  • Icon List content
  • Icon List content
  • Icon List content
import React from 'react';
import { List, ListItem } from 'react-magma-dom';
import { EmailIcon } from 'react-magma-icons';
export function Example() {
return (
<List spacingStyle="spacing02">
<ListItem
icon={<EmailIcon />}
iconColor="danger"
iconBackground="neutral300"
>
Icon List content
</ListItem>
<ListItem
icon={<EmailIcon />}
iconColor="primary"
iconBackground="neutral200"
>
Icon List content
</ListItem>
<ListItem
icon={<EmailIcon />}
iconColor="success"
iconBackground="neutral100"
>
Icon List content
</ListItem>
</List>
);
}

Inverse

The isInverse prop will render a dark background and light text. The children will inherit the isInverse prop unless specified otherwise.

  • List content
  • List content
  • List content
  • List content
  • List content
import React from 'react';
import { Card, CardBody, List, ListItem } from 'react-magma-dom';
export function Example() {
return (
<Card isInverse>
<CardBody>
<List isInverse>
<ListItem>List content</ListItem>
<ListItem>List content</ListItem>
<ListItem>List content</ListItem>
<ListItem>List content</ListItem>
<ListItem>List content</ListItem>
</List>
</CardBody>
</Card>
);
}

Definition List

Use the DefinitionList for groups of terms and descriptions, such as glossaries or key-value pairs.

Default Styles

Coffee
A hot beverage
Tea
Another hot beverage
Milk
A cold beverage

Custom Styles

Coffee
Tea
Hot Chocolate
A hot beverage
Milk
Lemonade
Margarita
A cold beverage
import React from 'react';
import styled from '@emotion/styled';
import {
Card,
CardBody,
Paragraph,
DefinitionList,
DefinitionListItem,
DefinitionListType,
} from 'react-magma-dom';
export function Example() {
const data = [
{ term: 'Coffee', description: 'A hot beverage' },
{ term: 'Tea', description: 'Another hot beverage' },
{ term: 'Milk', description: 'A cold beverage' },
];
const dataWithMultipleTerms = [
{
term: ['Coffee', 'Tea', 'Hot Chocolate'],
description: 'A hot beverage',
},
{
term: ['Milk', 'Lemonade', 'Margarita'],
description: 'A cold beverage',
},
];
const Row = styled.div`
display: flex;
align-items: flex-end;
margin-bottom: 16px;
`;
const TermStyled = styled.div`
display: flex;
flex-direction: column;
text-align: left;
`;
const DescriptionStyled = styled.div`
text-align: right;
`;
return (
<>
<Card style={{ marginBottom: '32px' }}>
<CardBody>
<Paragraph noTopMargin>Default Styles</Paragraph>
<DefinitionList>
{data.map((item, index) => (
<React.Fragment key={index}>
<DefinitionListItem type="term">{item.term}</DefinitionListItem>
<DefinitionListItem type="description">
{item.description}
</DefinitionListItem>
</React.Fragment>
))}
</DefinitionList>
</CardBody>
</Card>
<Card style={{ marginBottom: '32px' }}>
<CardBody>
<DefinitionList>
<Paragraph noTopMargin>Custom Styles</Paragraph>
{dataWithMultipleTerms.map((item, index) => (
<Row key={index}>
<TermStyled>
{item.term.map((term, i) => (
<DefinitionListItem
key={`term-${index}-${i}`}
type={DefinitionListType.term}
>
{term}
</DefinitionListItem>
))}
</TermStyled>
<DescriptionStyled>
<DefinitionListItem
key={`desc-${index}`}
type={DefinitionListType.description}
>
{item.description}
</DefinitionListItem>
</DescriptionStyled>
</Row>
))}
</DefinitionList>
</CardBody>
</Card>
</>
);
}

List Props

Any other props supplied will be provided to the wrapping div element.

children

Required

Description

The content of the component

Type

ReactNode | undefined

Default

-


hasStart

Description

Allows an ordered list to start at a determined value of a letter or number.

Type

string

Default

-


iconAlign

Description

Aligns the icon at the top, or center of each list item.

Type

enum, one of:
IconAlignment.center
IconAlignment.top

Default

IconAlignment.center


iconSize

Description

Sizes the icon between small, medium, and large.

Type

enum, one of:
IconSizes.large
IconSizes.medium
IconSizes.small

Default

IconSizes.medium


isInverse

Description

If true, the component will have inverse styling to better appear on a dark background

Type

boolean

Default

false


isOrdered

Type

boolean

Default

false


isReversed

Description

If list is ordered, then this allows the list to reverse the content.

Type

boolean

Default

false


listType

Description

Options for list type bullet formatting.

Type

ulListType | olListType

Default

-


spacingStyle

Description

Adds a bottom margin to each list item with the Magma space scale.

Type

function

Default

-


visualStyle

Description

Applies visual styles including font-size, font-weight, line-height and margins

Type

enum, one of:
TypographyVisualStyle.bodyLarge
TypographyVisualStyle.bodyMedium
TypographyVisualStyle.bodySmall
TypographyVisualStyle.bodyXSmall
TypographyVisualStyle.heading2XLarge
TypographyVisualStyle.heading2XSmall
TypographyVisualStyle.headingLarge
TypographyVisualStyle.headingMedium
TypographyVisualStyle.headingSmall
TypographyVisualStyle.headingXLarge
TypographyVisualStyle.headingXSmall

Default

TypographyVisualStyle.bodyMedium


List Item Props

children

Required

Description

The content of the component

Type

ReactNode | undefined

Default

-


description

Deprecated

Type

boolean

Default

-


hasStart

Description

Allows an ordered list to start at a determined value of a letter or number.

Type

string

Default

-


icon

Description

For use with inline icons within list items.

Type

ReactElement |

Default

-


iconAlign

Description

Aligns the icon at the top, or center of each list item.

Type

enum, one of:
IconAlignment.center
IconAlignment.top

Default

IconAlignment.center


iconBackground

Description

Option for changing icon background with all Magma colors.

Type

function

Default

-


iconColor

Description

Option for changing icon color with all Magma colors.

Type

function

Default

-


iconSize

Description

Sizes the icon between small, medium, and large.

Type

enum, one of:
IconSizes.large
IconSizes.medium
IconSizes.small

Default

IconSizes.medium


isInverse

Description

If true, the component will have inverse styling to better appear on a dark background

Type

boolean

Default

false


isOrdered

Type

boolean

Default

false


isReversed

Description

If list is ordered, then this allows the list to reverse the content.

Type

boolean

Default

false


listType

Description

Options for list type bullet formatting.

Type

ulListType | olListType

Default

-


spacingStyle

Description

Adds a bottom margin to each list item with the Magma space scale.

Type

function

Default

-


visualStyle

Description

Applies visual styles including font-size, font-weight, line-height and margins

Type

enum, one of:
TypographyVisualStyle.bodyLarge
TypographyVisualStyle.bodyMedium
TypographyVisualStyle.bodySmall
TypographyVisualStyle.bodyXSmall
TypographyVisualStyle.heading2XLarge
TypographyVisualStyle.heading2XSmall
TypographyVisualStyle.headingLarge
TypographyVisualStyle.headingMedium
TypographyVisualStyle.headingSmall
TypographyVisualStyle.headingXLarge
TypographyVisualStyle.headingXSmall

Default

TypographyVisualStyle.bodyMedium


Definition List Props

children

Required

Description

The content of the component

Type

ReactNode | undefined

Default

-


Definition List Item Props

type

Required

Description

Types of definition list element. term: uses a <dt> (definition term) tag description: uses a <dd> (definition description) tag

Type

enum, one of:
DefinitionListType.description
DefinitionListType.term

Default

-


Deploys by Netlify