Icons
Every control icon in Tomato Player has a name, such as
play, settings or fullscreen. You can replace any of them by name, from plain SVG markup or from React components. That includes animated icon libraries such as @animateicons/react.Icon names
| Name | Shown on |
|---|---|
play, pause, replay | play button, big play button |
volumeHigh, volumeLow, volumeMuted | mute button |
fullscreen, fullscreenExit | fullscreen button |
pip | picture-in-picture button |
captions | captions button |
settings | settings menu trigger |
forward, backward | seek ±10 s buttons |
next, previous | playlist and "next episode" buttons |
cast | cast button |
chapters | chapters button |
theater | theater mode (Tube) |
check, chevron | settings menu marks |
Where icons come from
The player looks an icon up in three places, in this order:
- The
iconsoption ofcreatePlayer, which is yours. - The skin's own icon set.
- The built-in Tomato icons.
Each official skin ships its own set, drawn from a different open-source library:
| Skin | Icons | License |
|---|---|---|
| Minimal | Tomato (built in) | MIT |
| Cinema | Phosphor, light weight | MIT |
| Studio | Tabler, outline | MIT |
| Creator | Lucide | ISC |
| Learn | Heroicons, outline | MIT |
| Campus | Phosphor, bold, with filled play and pause | MIT |
| Stream | Tabler, filled | MIT |
| Tube | Material Symbols Rounded | Apache 2.0 |
| Feed | Heroicons, solid | MIT |
Each skin package includes the license in
THIRD_PARTY_NOTICES.md. The sets are generated by scripts/gen-icon-sets.py.Replace icons with SVG markup
Pass trusted SVG markup by name. Names you leave out keep the skin's icons.
jsimport { createPlayer } from '@tomato-player/core';import { cinema } from '@tomato-player/skin-cinema';createPlayer('#player', {src: 'movie.mp4',skin: cinema(),icons: {play: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',pause: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M7 5h4v14H7zM13 5h4v14h-4z"/></svg>',},});
The markup is inserted as-is, so only pass markup you control. Never pass user input. The player adds
class="tp-icon", data-tp-icon="<name>" and aria-hidden="true". The button around the icon carries the accessible label.A value can also be a function that returns an element. The player calls it each time a control shows that icon:
jsicons: {settings: () => {const el = document.createElement('span');el.className = 'my-gear';return el;},}
Give a skin its own icons
Pass
icons to createSkin:tsimport { createSkin } from '@tomato-player/ui';export const aurora = createSkin({name: 'aurora',css,icons: { play: '<svg ...>', settings: '<svg ...>' },build(player, root) { /* ... */ },});
Users of the skin can still override single icons, either with
aurora({ icons: { ... } }) or with createPlayer({ icons }). In your own controls, render icons through icon(player, name) from @tomato-player/ui, not svg(icons.x), so these overrides apply.Animated icons in React
<TomatoPlayer> from @tomato-player/react accepts React nodes in icons. Each node renders into its control through a portal, so animated components keep their motion and state:tsx'use client';import { TomatoPlayer } from '@tomato-player/react';import { minimal } from '@tomato-player/skin-minimal';import { PauseIcon, PlayIcon, SettingsIcon, Volume2Icon, VolumeXIcon, MaximizeIcon, MinimizeIcon } from '@animateicons/react/lucide';export function Video() {return (<TomatoPlayersrc="movie.mp4"skin={minimal()}icons={{play: <PlayIcon size={24} />,pause: <PauseIcon size={24} />,settings: <SettingsIcon size={24} />,volumeHigh: <Volume2Icon size={24} />,volumeMuted: <VolumeXIcon size={24} />,fullscreen: <MaximizeIcon size={24} />,fullscreenExit: <MinimizeIcon size={24} />,}}/>);}
@animateicons/react icons animate when the pointer is over the glyph. To start the animation when the pointer enters the whole button, call the icon's startAnimation() from the button's pointerenter event. The website's apps/website/src/components/animated-icons.tsx shows how.If you create the player yourself,
useIconPortals(set) returns icons for createPlayer and portals to render:tsxconst { icons, portals } = useIconPortals({ play: <PlayIcon />, pause: <PauseIcon /> });useEffect(() => {const player = createPlayer(ref.current!, { src, skin, icons });return () => player.destroy();}, [icons]);return <>{portals}<div ref={ref} /></>;
Styling
Icons are sized by
--tp-icon-size (22px by default) and use currentColor. Component icons render inside a <span class="tp-icon"> host, and the base CSS sizes the SVG inside it. Target one icon with [data-tp-icon='play']:css.tp[data-skin='aurora'] [data-tp-icon='play'] { fill: currentColor; }