2025-04-13 19次浏览

yiisoft/bootstrap5 包的首个稳定版本已发布。该包将 Bootstrap 5 UI 框架封装为 Yii 小部件,便于在 PHP 模板中使用,并支持主题定制等功能。

<?php
use Yiisoft\Bootstrap5\Carousel;
use Yiisoft\Bootstrap5\CarouselItem;
use Yiisoft\Html\Tag\Div;
use Yiisoft\Html\Tag\H2;
use Yiisoft\Html\Tag\P;
?>

<?= Carousel::widget()
    ->id('carouselExampleOnlyText')
    ->items(
        CarouselItem::to(
            Div::tag()
                ->addClass('bg-primary text-white p-5 text-center')
                ->addContent(
                    H2::tag()->content('Title 1'),
                    P::tag()->content('This is the first slide with text.'),
                ),
        ),
        CarouselItem::to(
            Div::tag()
                ->addClass('bg-success text-white p-5 text-center')
                ->addContent(
                    H2::tag()->content('Title 2'),
                    P::tag()->content('This is the second slide with text.'),
                ),
        ),
        CarouselItem::to(
            Div::tag()
                ->addClass('bg-danger text-white p-5 text-center')
                ->addContent(
                    H2::tag()->content('Title 3'),
                    P::tag()->content('This is the third slide with text.'),
                ),
        ),
    );

更多使用示例可查阅该包的用户指南