Carousel

View Source

NOTE: Introduced feature in v0.4.6.

Carousel allows the user to scroll through "slides" of content without having to extend the page dimensions.

<script>
    import {
        Box,
        Carousel,
        Center,
    } from "@kahi-ui/framework";
</script>

<Carousel.Container class="carousel-preview">
    <Carousel.Section>
        <Box palette="negative">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>

    <Carousel.Section>
        <Box palette="affirmative">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>

    <Carousel.Section>
        <Box palette="alert">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>
</Carousel.Container>

<style>
    :global(.carousel-preview) {
        width: 300px;
        height: 200px;
    }
</style>

Imports

<script>
    import {Carousel} from "@kahi-ui/framework";

    const {Container, Section} = Carousel;
</script>

Orientation

You can set the Carousel to render vertically via the orientation property.

<script>
    import {
        Box,
        Carousel,
        Center,
    } from "@kahi-ui/framework";
</script>

<Carousel.Container
    class="carousel-orientation"
    orientation="vertical"
>
    <Carousel.Section>
        <Box palette="negative">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>

    <Carousel.Section>
        <Box palette="affirmative">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>

    <Carousel.Section>
        <Box palette="alert">
            <Center height="100">300 x 200</Center>
        </Box>
    </Carousel.Section>
</Carousel.Container>

<style>
    :global(.carousel-orientation) {
        width: 300px;
        height: 200px;
    }
</style>

Spacing

NOTE: By passing an array, you can set responsive values. e.g. spacing={["medium", "tablet:small", "mobile:tiny"]}

You can adjust the spacing between items via the spacing, spacing_x, and spacing_y properties.

<script>
    import {
        Box,
        Carousel,
        Center,
        Stack,
        Text,
    } from "@kahi-ui/framework";
</script>

<Stack.Container
    class="carousel-spacing"
    orientation="horizontal"
    spacing="medium"
    variation="wrap"
>
    <div>
        <Text is="strong">DEFAULT</Text>

        <Carousel.Container>
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">NANO</Text>

        <Carousel.Container spacing="nano">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">TINY</Text>

        <Carousel.Container spacing="tiny">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">SMALL</Text>

        <Carousel.Container spacing="small">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">MEDIUM</Text>

        <Carousel.Container spacing="medium">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">LARGE</Text>

        <Carousel.Container spacing="large">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">HUGE</Text>

        <Carousel.Container spacing="huge">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>

    <div>
        <Text is="strong">MASSIVE</Text>

        <Carousel.Container spacing="massive">
            <Carousel.Section>
                <Box palette="negative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="affirmative">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>

            <Carousel.Section>
                <Box palette="alert">
                    <Center height="100">
                        300 x 200
                    </Center>
                </Box>
            </Carousel.Section>
        </Carousel.Container>
    </div>
</Stack.Container>

<style>
    :global(.carousel-spacing) :global(.carousel) {
        width: 300px;
        height: 200px;
    }
</style>

Properties

Carousel.Container

Name Description Types
orientation Renders the Carousel vertically.
horizontal (DEFAULT) vertical
spacing Adjusts the visual spacing between child items in the Carousel.
nano tiny small medium large huge massive {VIEWPORT}:{SPACING}
spacing_x Adjusts the horizontal visual spacing between child items in the Carousel.
nano tiny small medium large huge massive {VIEWPORT}:{SPACING}
spacing_y Adjusts the vertical visual spacing between child items in the Carousel.
nano tiny small medium large huge massive {VIEWPORT}:{SPACING}

Slots

Carousel.Container

Name Description Types
default Default unnamed slot.
{}

Carousel.Section

Name Description Types
default Default unnamed slot.
{}