Looking for the old docs? Go here

Styling

Tailwind CSS

A guide on installing and using the Tailwind CSS plugin.

If you’re a fan of Tailwind CSS like we are, then you really don’t want to be forced to create a .css file to handle random outlier cases. It not only slows you down and breaks your flow, but it also goes against all the advantages of using utility classes. Our Tailwind plugin provides you with media variants such as media-paused:opacity-0 to help you easily style elements based on media state.

You can register the plugin by adding the following to tailwind.config.js:

tailwind.config.js
  
    
  

The following options are available:

  
    
  

The Tailwind plugin provides media variants which can be used to prefix utilities so they’re applied when a given media state is active (or not). Here are some examples:

  
    
  
  
    
  
VariantDescription
media-autoplay-errorAutoplay has failed to start.
media-autoplayAutoplay has successfully started.
media-bufferingMedia is not ready for playback or waiting for more data.
media-can-controlMedia is ready for playback and user is not idle.
media-can-fullscreenMedia fullscreen is available.
media-can-loadMedia can begin loading.
media-can-pipPicture-in-Picture is available.
media-can-playMedia is ready to be played.
media-can-seekWhether seeking is permitted for live stream.
media-captionsCaption or subtitle text track is showing.
media-controlsControls are visible.
media-ios-controlsNative iOS controls are visible.
media-endedPlayback has reached the end.
media-errorIssue with media loading/playback.
media-fullscreenMedia is in fullscreen mode.
media-live-edgeCurrent time is at the live edge.
media-liveMedia is a live stream.
media-loopMedia is set to loop back to start on end.
media-mutedMedia is muted.
media-pausedPlayback is in a paused state.
media-pipMedia is in picture-in-picture mode.
media-playingPlayback has started or resumed.
media-playsinlineMedia should play inline by default (iOS Safari).
media-previewTime slider preview is visible.
media-seekingMedia or user is seeking to new playback position.
media-startedMedia playback has started.
media-user-idleUser is not active during playback.
media-waitingMedia is waiting for more data (i.e., buffering).

All media variants can be prefixed with not- to negate the selector. Classes with this prefix will be transformed into media-player:not([state]) selectors.

  
    
  

Few more examples:

  • not-media-paused: Media is in the play state (not paused).
  • not-media-playing: Media playback is not active (not playing).
  • not-media-can-play: Media is not ready for playback (not can play).

Data attributes are applied to components throughout the library to expose internal state for styling purposes. Tailwind supports data attributes out of the box to apply styles conditionally.

  
    
  
INFO

All component API references include the exposed data attributes. See the player data attributes as an example.

The data-focus attribute is applied to all components when focused via keyboard. This attribute can be used to apply focus styling like so:

  
    
  

The data-hocus attribute is applied to components when they’re being keyboard focused or hovered on by a pointer device. This attribute is applied to help keep class lists concise and can be used like so: