承接 bensomething/craft-tabler-icons 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bensomething/craft-tabler-icons

Composer 安装命令:

composer require bensomething/craft-tabler-icons

包简介

Tabler icon picker field for Craft CMS

README 文档

README

A field type for selecting a Tabler icon from a searchable picker, and rendering any icon as inline SVG in your templates.

  • 5,000+ outline icons and 1,000+ filled icons (Tabler Icons v3.44), bundled with the plugin
  • Searchable by name, tags, and category, with outline/filled tabs
  • Inline SVG rendering with custom attributes, plays nicely with Tailwind
  • tabler() Twig function for hardcoding icons without a field
  • Field setting to limit picker to outline-only or filled-only icons

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+

Installation

composer require bensomething/craft-tabler-icons
php craft plugin/install tabler

Or install from the control panel: Settings → Plugins.

Installing straight from GitHub (if not using Packagist): add { "type": "vcs", "url": "https://github.com/bensomething/craft-tabler-icons" } to the repositories array in your project's composer.json first.

Package Size

The full Tabler icon set is bundled with the plugin, which makes it around 25MB on disk (roughly 3MB compressed for the actual download). In return, everything works offline. The picker, search, and SVG rendering make no CDN or API calls, icons can never change or disappear underneath your content, and front-end rendering is a local file read rather than an HTTP request.

The Field

Create a field of type Tabler Icon and add it to a field layout. Authors get a Choose icon button that opens a searchable icon grid.

Field settingsIcon Style controls whether authors can pick from both styles, outline only, or filled only. Selecting Outline and filled will display Outline and Filled tabs in the icon picker.

Templating

The field value is null or an Icon object:

{# Inline SVG at its native 24×24 #}
{{ entry.myIcon }}

{# With attributes — `size` sets width and height,
   `strokeWidth` is an alias for stroke-width (outline icons only) #}
{{ entry.myIcon.svg({ size: 32, class: 'text-red-500', strokeWidth: 1.5 }) }}

{# Guard against empty values #}
{% if entry.myIcon %}
    {{ entry.myIcon.svg({ size: 20 }) }}
{% endif %}

{# Properties #}
{{ entry.myIcon.name }}        {# "ad-off" #}
{{ entry.myIcon.label }}       {# "Ad Off" #}
{{ entry.myIcon.variant }}     {# "outline" or "filled" #}

Icons inherit currentColor, so they take the CSS text colour of their parent. SVGs render with aria-hidden="true" by default. Pass an aria-label for icons that carry meaning.

Default Attributes

Set site-wide SVG defaults in a config/tabler.php file in your project:

<?php

return [
    'svgDefaults' => [
        'class' => 'text-highlight',
        'stroke-width' => 1.5,
        'stroke-linecap' => 'square',
        'stroke-linejoin' => 'bevel',
    ],
];

Every svg() call (and bare icon output) starts from these. Per-call attributes override defaults, except class, which is combined:

{{ item.icon.svg({ class: 'size-8 mb-2' }) }}   {# class="… text-highlight size-8 mb-2" stroke-width="1.5" … #}
{{ item.icon.svg({ strokeWidth: 2.5 }) }}       {# overrides the configured stroke-width #}
{{ item.icon.svg({ defaults: false }) }}        {# skips the configured defaults entirely #}

Manual Icons (No Field)

The tabler() Twig function returns the same Icon object for any icon name:

{{ tabler('map-pin') }}
{{ tabler('map-pin').svg({ size: 20, class: 'list-icon' }) }}
{{ tabler('heart', 'filled').svg({ size: 20 }) }}
{{ tabler('heart-filled') }}   {# '-filled' suffix also selects the filled variant #}

tabler() also accepts an existing Icon object (e.g. a field value) and returns it unchanged — handy for partials that take either a name or a field value:

{{ tabler(item.myIcon ?? 'star').svg({ size: 20 }) }}

Unknown icon names render as an empty string.

With Tailwind

Skip size and use utility classes, CSS wins over the SVG's intrinsic width/height attributes:

{{ tabler('calendar').svg({ class: 'size-4 sm:size-6 shrink-0 text-emerald-600' }) }}

Webfont Classes

If you load the Tabler webfont on the front end yourself, classes() gives you the class names:

<i class="{{ entry.myIcon.classes() }}"></i>   {# "ti ti-ad-off" / "ti ti-heart-filled" #}

License

This plugin is MIT-licensed. Tabler Icons are © Paweł Kuna, also MIT-licensed (see LICENSE-tabler).

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固