# Lists

Use lists to implement `<ol>`, `<ul>` and `<li>`-tags.

## Parameters

Both list definitions (`<ol>` and `<ul>`) and list elements (`<li>`) can take 2 optional configuration params. List elements (`<li>`) can also take a third param, text input.

### id (optional)

Expects a string with all ids the element should have.

### class (optional)

Expects a string with all classes the element should have.

### text (optional)

Expects a string which will be rendered between the opening and closing `<li>`-tag

## Example 1

Implementing a simple ordered list.

```ruby
ol id: "foo" do
  li text: "bar"
end
```

returns

```markup
<ol id="foo">
  <li>bar</li>
</ol>
```

## Example 2

Implementing a simple unordered list that shows both options you have to pass arguments to list elements

```ruby
@base = mate
# ...
ul do
  li text: "foo"
  li do
    plain "bar"
  end
  li do
    plain @base
  end
end
```

returns

```markup
<ul>
  <li>foo</li>
  <li>bar</li>
  <li>mate</li>
</ul>
```

## Example 3

The real beauty comes into play when things get a little more complicated

```ruby
@users = ["Jonas", "Pascal", "Chris"]
# ...
ul do
  @users.each do |user|
    li text: user
  end
end
```

returns

```markup
<ul>
  <li>Jonas</li>
  <li>Pascal</li>
  <li>Chris</li>
</ul>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.matestack.io/matestack-ui-core/1.5.0/components-api/core-components/list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
