Skip to content

Tile

The Tile component provides a versatile way to create interactive, animated tiles in various sizes with different effects. Tiles can be used to create a Windows-style tile interface or any grid-based layout with interactive elements.

  • DOM Library
<div data-role="tile"></div>
<div data-role="tile" data-size="wide" data-effect="slide-up"></div>
<div data-role="tile">
<span class="mif-facebook icon"></span>
<span class="branding-bar">Facebook</span>
</div>
<div data-role="tile" class="bg-red">
<span class="badge-top">10</span>
<span class="badge-bottom">5</span>
</div>
<div class="tiles-grid">
<div data-role="tile" data-size="small">Tile 1</div>
<div data-role="tile" data-size="medium">Tile 2</div>
<div data-role="tile" data-size="wide">Tile 3</div>
<div data-role="tile" data-size="large">Tile 4</div>
</div>
<div data-role="tile" data-effect="slide-up" data-size="wide">
<div class="slide" data-cover="./images/image1.jpg"></div>
<div class="slide" data-cover="./images/image2.jpg"></div>
<div class="slide" data-cover="./images/image3.jpg"></div>
</div>
<div data-role="tile" data-size="wide" data-effect="image-set">
<img src="./images/image1.jpg" alt="">
<img src="./images/image2.jpg" alt="">
<img src="./images/image3.jpg" alt="">
<img src="./images/image4.jpg" alt="">
<img src="./images/image5.jpg" alt="">
</div>
<div data-role="tile" class="effect-hover-slide-up">
<div class="slide-front" data-cover="./images/image1.jpg"></div>
<div class="slide-back" data-cover="./images/image2.jpg"></div>
</div>
ParameterTypeDefaultDescription
tileDeferrednumber0Delay before initialization
sizestring”medium”Size of the tile. Possible values: “small”, “medium”, “wide”, “large”, “app”
coverstring""URL to the background image
coverPositionstring”center”Position of the background image
effectstring""Animation effect for the tile. Possible values: “slide-up”, “slide-down”, “slide-left”, “slide-right”, “fade”, “zoom”, “swirl”, “switch”, “image-set”
effectIntervalnumber3000Interval between animation effects in milliseconds
effectDurationnumber500Duration of the animation effect in milliseconds
targetstringnullURL to navigate to when the tile is clicked
canTransformbooleantrueWhether the tile can transform when clicked
onTileClickfunctionMetro.noopCallback function when the tile is clicked
onTileCreatefunctionMetro.noopCallback function when the tile is created
  • _runEffects() - Starts the animation effects for the tile
  • _stopEffects() - Stops the animation effects for the tile
  • _setCover(element, src, position) - Sets the background image for the tile
  • destroy() - Removes the tile and its event handlers
const tile = Metro.getPlugin('#myTile', 'tile');
tile.destroy();
EventDescription
onTileClickTriggered when the tile is clicked
onTileCreateTriggered when the tile is created
VariableDefault (Light)Dark ModeDescription
--tile-background#ededed#26282eBackground color of the tile
--tile-color#191919#ffffffText color of the tile
--tile-border-colorvar(—border-color)var(—border-color)Border color of the tile
--tile-border-radius6px6pxBorder radius of the tile
--tile-badge-backgroundrgba(25, 25, 25, 0.1)rgba(25, 25, 25, 0.1)Background color of the badge
--tile-badge-color#191919#ffffffText color of the badge
--tile-grid-gap10px10pxGap between tiles in a grid
.my-custom-tile {
--tile-background: #3498db;
--tile-color: #ffffff;
--tile-border-radius: 10px;
}
  • .tile-small - Small tile (70px x 70px)
  • .tile-medium - Medium tile (150px x 150px)
  • .tile-wide - Wide tile (310px x 150px)
  • .tile-large - Large tile (310px x 310px)
  • .tile-app - App tile (44px x 44px)
  • .icon - Icon inside the tile
  • .branding-bar - Bar at the bottom of the tile
  • .badge-top - Badge at the top right of the tile
  • .badge-bottom - Badge at the bottom right of the tile
  • .slide - Slide for animation effects
  • .slide-front - Front slide for hover effects
  • .slide-back - Back slide for hover effects
  • .transform-right - Transformation effect when clicked on the right side
  • .transform-left - Transformation effect when clicked on the left side
  • .transform-top - Transformation effect when clicked on the top side
  • .transform-bottom - Transformation effect when clicked on the bottom side
  • .effect-hover-slide-up - Slide up effect on hover
  • .effect-hover-slide-down - Slide down effect on hover
  • .effect-hover-slide-left - Slide left effect on hover
  • .effect-hover-slide-right - Slide right effect on hover
  • .effect-hover-zoom-up - Zoom up effect on hover
  • .effect-hover-zoom-down - Zoom down effect on hover
  • .effect-hover-zoom-left - Zoom left effect on hover
  • .effect-hover-zoom-right - Zoom right effect on hover
  • .image-set - Special effect for displaying multiple images in a tile
  • .tiles-grid - Grid layout for tiles
  • .tiles-group - Group of tiles with a title