pub struct CodeProps {Show 18 fields
pub variant: CodeVariant,
pub code: Option<String>,
pub language: Option<String>,
pub label: Option<String>,
pub copy: bool,
pub appearance: CodeAppearance,
pub theme: CodeTheme,
pub wrap: bool,
pub highlighted: bool,
pub code_label: Option<String>,
pub copy_label: Option<String>,
pub copied_label: Option<String>,
pub error_label: Option<String>,
pub recovery_label: Option<String>,
pub on_copy: Option<Callback<String, bool>>,
pub class: Option<String>,
pub attributes: Vec<Attribute>,
pub children: Element,
}Expand description
Props for Code().
Fields§
§variant: CodeVariantInline code or a block.
code: Option<String>Source text. Blocks tokenize it for highlighting; without it, children render as is.
language: Option<String>Language used for highlighting and shown in the block header, such as ts or bash.
label: Option<String>Text shown in the block header, such as a file name.
copy: boolAdds a copy button to the block header.
appearance: CodeAppearanceHeader style of a block.
theme: CodeThemeSyntax color theme.
wrap: boolWraps long lines instead of scrolling the block.
highlighted: boolRenders children as already highlighted markup, such as a pre from a build-time
highlighter.
code_label: Option<String>Accessible name of the scrollable code region. Defaults to “Code example”.
copy_label: Option<String>Accessible name of the copy button. Defaults to “Copy code to clipboard”.
copied_label: Option<String>Name and announcement after a copy. Defaults to “Code copied to clipboard”.
error_label: Option<String>Name and announcement after a failed copy.
recovery_label: Option<String>Shows a read-only text area with the code after a failed copy, under this label.
on_copy: Option<Callback<String, bool>>Copies through the app instead of the browser clipboard. Called with the text; returns whether the copy succeeded. Use it on Dioxus Native.
class: Option<String>Extra classes appended after the Lumen classes.
attributes: Vec<Attribute>Any other global attribute, set on the <code> or <figure>.
children: ElementCode content when code is not set.
Implementations§
Source§impl CodeProps
impl CodeProps
Sourcepub fn builder() -> CodePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> CodePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building CodeProps.
On the builder, call .variant(...)(optional), .code(...)(optional), .language(...)(optional), .label(...)(optional), .copy(...)(optional), .appearance(...)(optional), .theme(...)(optional), .wrap(...)(optional), .highlighted(...)(optional), .code_label(...)(optional), .copy_label(...)(optional), .copied_label(...)(optional), .error_label(...)(optional), .recovery_label(...)(optional), .on_copy(...)(optional), .class(...)(optional), .attributes(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of CodeProps.
Trait Implementations§
Source§impl Properties for CodePropswhere
Self: Clone,
impl Properties for CodePropswhere
Self: Clone,
Source§type Builder = CodePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
type Builder = CodePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Source§fn memoize(&mut self, new: &Self) -> bool
fn memoize(&mut self, new: &Self) -> bool
Source§fn into_vcomponent<M>(
self,
render_fn: impl ComponentFunction<Self, M>,
) -> VComponentwhere
M: 'static,
fn into_vcomponent<M>(
self,
render_fn: impl ComponentFunction<Self, M>,
) -> VComponentwhere
M: 'static,
impl StructuralPartialEq for CodeProps
Auto Trait Implementations§
impl !Freeze for CodeProps
impl !RefUnwindSafe for CodeProps
impl !Send for CodeProps
impl !Sync for CodeProps
impl !UnwindSafe for CodeProps
impl Forget for CodeProps
impl Move for CodeProps
impl Unpin for CodePropswhere
*const u8 is !null: Unpin,
&'static UnsyncStorage: Unpin,
NonZero<u64>: Unpin,
&'static Location<'static>: Unpin,
Box<dyn FnMut(String) -> bool>: Unpin,
*const RcInner<Runtime> is !null: Unpin,
&'static str: Unpin,
Rc<RefCell<dyn FnMut(Event<dyn Any>)>>: Unpin,
Rc<dyn AnyValue>: Unpin,
Rc<VNodeInner>: Unpin,
Arc<Error>: Unpin,
NonZero<u32>: Unpin,
impl UnsafeUnpin for CodePropswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static UnsyncStorage: UnsafeUnpin,
NonZeroU64Inner: UnsafeUnpin,
&'static Location<'static>: UnsafeUnpin,
PhantomData<Option<ExternalListenerCallback<String, bool>>>: UnsafeUnpin,
PhantomData<Attribute>: UnsafeUnpin,
*const RcInner<VNodeInner> is !null: UnsafeUnpin,
PhantomData<RcInner<VNodeInner>>: UnsafeUnpin,
*const ArcInner<Error> is !null: UnsafeUnpin,
PhantomData<ArcInner<Error>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more