Inline_svg

screenshot of Inline_svg
rails

Embed SVG documents in your Rails views and style them with CSS

Overview

The Inline SVG integration for Rails is a powerful gem that facilitates the embedding of SVG documents directly into your HTML views. By applying CSS classes and ensuring accessibility features right from the start, this tool enhances your web design workflow. With support for Rails 7.x and compatibility with Sprockets or Shakapacker, this gem is a game-changer for developers looking to streamline their SVG management.

By using the helper methods provided, you can easily incorporate SVGs, ensuring they are styled and functional according to your project's needs. Whether you are handling multiple SVG files or just a single one, the Inline SVG gem not only simplifies the process but also optimizes your documents for maintainability and performance.

Features

  • SVG Embedding: Easily embed SVG documents inline with helper methods like inline_svg_tag and inline_svg_pack_tag, which automatically apply custom styles.

  • CSS Class Application: Add CSS classes to the root of your SVG documents to ensure they match your website's styling seamlessly.

  • Accessibility Support: Automatically integrate important accessibility attributes, such as role="img" and aria-labelledby, to enhance usability for all users.

  • Flexible File Input: Accepts various ways to reference SVG files, from full paths and basenames to IO objects, allowing for great flexibility in asset management.

  • Custom Attributes: Set attributes like id, class, style, title, and desc directly within the embedding method for better control over your SVGs.

  • Aspect Ratio Preservation: Maintain the correct aspect ratio of your SVGs with the preserve_aspect_ratio attribute, ensuring your graphics display beautifully across different devices.

  • Pre-processing and Fingerprinting: Benefit from pre-processing and fingerprinting of SVG files, treating them like other Rails assets to enhance performance and caching.

  • Fallback Support: Specify fallback SVG documents to ensure a consistent experience even if the primary SVG fails to load.

rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.