class Primer::TruncateComponent
Use TruncateComponent to shorten overflowing text with an ellipsis.
def call
def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end
def initialize(inline: false, expandable: false, max_width: nil, **system_arguments)
-
system_arguments(Hash) -- <%= link_to_system_arguments_docs %> -
max_width(Integer) -- Sets the max-width of the text. -
expandable(Boolean) -- Whether the entire string should be revealed on hover. Can only be used in conjunction with `inline`. -
inline(Boolean) -- Whether the element is inline (or inline-block).
Other tags:
- Example: Custom size -
Example: Expandable -
Example: Inline -
Example: Default -
def initialize(inline: false, expandable: false, max_width: nil, **system_arguments) @system_arguments = system_arguments @system_arguments[:tag] ||= :div @system_arguments[:classes] = class_names( @system_arguments[:classes], "css-truncate", "css-truncate-overflow" => !inline, "css-truncate-target" => inline, "expandable" => inline && expandable ) @system_arguments[:style] = join_style_arguments(@system_arguments[:style], "max-width: #{max_width}px;") unless max_width.nil? end