Convert Figma logo to code with AI

ghosh logomicrotip

💬 Minimal, accessible, ultra lightweight css tooltip library. Just 1kb.

1,383
74
1,383
29

Top Related Projects

11,981

Tooltip, popover, dropdown, and menu library

A CSS only tooltip library for your lovely websites.

A fresher "Fork me on GitHub" callout.

22,727

A light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the page

Quick Overview

Microtip is a lightweight, modern tooltip library for web applications. It provides a simple way to add tooltips to HTML elements without any dependencies, making it easy to integrate into various projects.

Pros

  • Lightweight and dependency-free
  • Easy to use and customize
  • Supports multiple positions for tooltips
  • Responsive and works well on mobile devices

Cons

  • Limited advanced features compared to more comprehensive tooltip libraries
  • May require additional styling for complex designs
  • Documentation could be more extensive

Code Examples

Adding a basic tooltip:

<button data-microtip="This is a tooltip" data-microtip-position="top">
  Hover me
</button>

Creating a tooltip with HTML content:

<span data-microtip="<strong>Bold</strong> and <em>italic</em>" data-microtip-position="right" data-microtip-size="large">
  HTML tooltip
</span>

Customizing tooltip appearance with CSS:

[aria-label][role~="tooltip"] {
  background: #333;
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
}

Getting Started

  1. Include the Microtip CSS file in your HTML:
<link rel="stylesheet" href="https://unpkg.com/microtip/microtip.css">
  1. Add the data-microtip attribute to the element you want to add a tooltip to:
<button data-microtip="Hello, I'm a tooltip!">Hover me</button>
  1. Optionally, specify the position using data-microtip-position:
<button data-microtip="I'm on the left" data-microtip-position="left">Left tooltip</button>

That's it! Microtip will automatically apply tooltips to elements with the data-microtip attribute.

Competitor Comparisons

11,981

Tooltip, popover, dropdown, and menu library

Pros of Tippyjs

  • More feature-rich with extensive customization options
  • Better browser compatibility, including IE11 support
  • Larger community and more frequent updates

Cons of Tippyjs

  • Larger file size, which may impact page load times
  • Steeper learning curve due to more complex API
  • Requires additional setup for certain frameworks

Code Comparison

Microtip:

<button data-microtip="Tooltip content" data-microtip-position="top">
  Hover me
</button>

Tippyjs:

tippy('#myButton', {
  content: 'Tooltip content',
  placement: 'top',
});

Summary

Tippyjs offers a more comprehensive tooltip solution with extensive features and customization options, making it suitable for complex projects. It has better browser support and a larger community. However, this comes at the cost of a larger file size and a more complex API.

Microtip, on the other hand, provides a simpler, lightweight solution that's easy to implement with minimal setup. It's ideal for projects that require basic tooltip functionality without the need for extensive customization.

The choice between the two depends on the project's requirements, with Tippyjs being better for feature-rich applications and Microtip for simpler, performance-focused implementations.

A CSS only tooltip library for your lovely websites.

Pros of hint.css

  • More customization options and themes out of the box
  • Supports more positioning options (top, bottom, left, right, and corners)
  • Larger community and more frequent updates

Cons of hint.css

  • Larger file size (~ 6KB minified vs. ~ 1KB for microtip)
  • More complex setup and usage compared to microtip's simplicity
  • Requires additional HTML attributes for styling and positioning

Code Comparison

hint.css:

<p class="hint--top" aria-label="This is a tooltip">Hover me</p>

microtip:

<button aria-label="This is a tooltip" data-microtip-position="top" role="tooltip">Hover me</button>

Both libraries use HTML attributes to define tooltips, but hint.css relies on CSS classes for positioning, while microtip uses data attributes. hint.css offers more flexibility in styling and positioning, but microtip's approach is more straightforward and aligns better with ARIA standards.

hint.css provides a wider range of features and customization options, making it suitable for projects requiring complex tooltip implementations. microtip, on the other hand, excels in simplicity and lightweight design, making it ideal for projects where minimal overhead is crucial.

A fresher "Fork me on GitHub" callout.

Pros of github-corners

  • Provides visually appealing and customizable GitHub corner ribbons
  • Lightweight and easy to implement with a single SVG element
  • Offers animation effects for enhanced user interaction

Cons of github-corners

  • Limited to GitHub corner ribbons, less versatile than general-purpose tooltips
  • Requires manual customization for different color schemes
  • May not be suitable for projects not hosted on GitHub

Code Comparison

microtip:

<button data-microtip="This is a tooltip" data-microtip-position="top">
  Hover me
</button>

github-corners:

<a href="https://your-url" class="github-corner" aria-label="View source on GitHub">
  <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
    <!-- SVG path data -->
  </svg>
</a>

Summary

microtip is a versatile tooltip library that can be used for various purposes, while github-corners focuses specifically on adding GitHub corner ribbons to websites. microtip offers more flexibility in terms of content and positioning, whereas github-corners provides a visually appealing and animated way to link to GitHub repositories. The choice between the two depends on the specific needs of the project and whether a general tooltip solution or a GitHub-specific element is required.

22,727

A light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the page

Pros of driver.js

  • More feature-rich, offering guided tours, highlighting elements, and customizable overlays
  • Actively maintained with regular updates and a larger community
  • Extensive documentation and examples available

Cons of driver.js

  • Larger file size and potentially more complex to implement
  • May be overkill for simple tooltip needs
  • Requires more setup and configuration for basic use cases

Code Comparison

microtip:

<button data-microtip="This is a tooltip" data-microtip-position="top">
  Hover me
</button>

driver.js:

const driver = new Driver();
driver.highlight({
  element: '#my-element',
  popover: {
    title: 'Title',
    description: 'Description'
  }
});

Summary

microtip is a lightweight, CSS-only tooltip library that's easy to implement for simple use cases. It requires minimal setup and is ideal for basic tooltip needs.

driver.js, on the other hand, is a more comprehensive solution for creating guided tours, highlighting elements, and providing interactive onboarding experiences. It offers greater flexibility and customization options but comes with a larger footprint and more complex implementation.

Choose microtip for quick, simple tooltips, and driver.js for more advanced user guidance and interactive experiences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Made with love License Build Status

Modern, minimal css tooptip library with accessibility baked in. Just `1kb` minified and gzipped.


Microtip

 

Table of Contents

 

Installation

via npm

npm install microtip

via yarn

yarn add microtip

via CDN

https://unpkg.com/microtip/microtip.css

direct download

curl -o microtip https://github.com/ghosh/microtip/blob/master/microtip.css

 

Setup

in PostCSS

@import 'microtip';

in Webpack

import microtip from 'microtip/microtip.css'

in SCSS

@import 'microtip/microtip';

Make sure, node_modules is included in the includePaths setting. You can then directly import the library into your file.

 

Usage

Using the tooltip is incredibly simple. Simply add a aria-label and role="tooltip" attribute to the element on which you want the tooltip to appear. The tooltip message is the attribute value aria-label="your message". This along with a position modifier is all you need to get going. Example:-

<button aria-label="Hey tooltip!" data-microtip-position="top" role="tooltip">

Position Modifiers

You can change the direction of the tooltip by adding a data-microtip-position attribute. The accepted values of this attribute are:- top, top-left, top-right, bottom, bottom-left, bottom-right, left and right. Example:-

<button aria-label="Hey tooltip!" data-microtip-position="top-left" role="tooltip">

Size Modifiers

By default, the tooltip will takeup only the size it requires to show the text. You can specify sizes by adding a data-microtip-size attribute. The accepted values include small, medium, large and fit. Example:-

<button aria-label="This is a decently long text!" data-microtip-position="top-left" data-microtip-size="medium" role="tooltip">

Note - fit sets the width of the tooltip to be the same as the width on the element. It only works along with the top and bottom position modifiers.

 

Customization

Microtip uses css variables, which allows you to customize the behavior of the tooltip as per your needs.

VariableDescriptionDefault Value
--microtip-transition-durationSpecifies the duration of the tootltip transition.18s
--microtip-transition-delayThe delay on hover before showing the tooltip0s
--microtip-transition-easingThe easing applied while transitioning the tooltipease-in-out
--microtip-font-sizeSets the font size of the text in tooltip13px
--microtip-font-weightThe font weight of the text in tooltipnormal
--microtip-text-transformControls the casing of the textnone

 

Example:-

:root {
 --microtip-transition-duration: 0.5s;
 --microtip-transition-delay: 1s;
 --microtip-transition-easing: ease-out;
 --microtip-font-size: 13px;
 --microtip-font-weight: bold;
 --microtip-text-transform: uppercase;
}

The above code will cause all the tooltips to transition over 0.5s while applying an easing of type ease-out after a delay of 1s. The text will be bold and uppercase and have a font size of 13px.

You could also customize the tooltip for individual instances by using a selector more specific than :root. Example:-

.tooltip {
 --microtip-transition-duration: 0.2s;
 --microtip-transition-delay: 0s;
 --microtip-transition-easing: ease-in-out;
}

The above code would only affect the tooltips shown on any element with the tooltip class.

For more on css variables see here

 

Related

  • Micromodal - Tiny javascript library for creating accessible modal dialogs

 

Credits

 

✌️

A little project by @i_ghosh

NPM DownloadsLast 30 Days