Crate nih_plug_iced

source ·
Expand description

iced editor support for NIH plug.

This integration requires you to pass your parameters to your editor object through the IcedEditor::InitializationFlags, and to add a message type for your editor to handle parmater updates. This is a minimal example:

use nih_plug_iced::*;

pub(crate) fn default_state() -> Arc<IcedState> {
    IcedState::from_size(200, 150)

pub(crate) fn create(
    params: Arc<FooParams>,
    editor_state: Arc<IcedState>,
) -> Option<Box<dyn Editor>> {
    create_iced_editor::<Foo>(editor_state, params)

struct FooEditor {
    params: Arc<FooParams>,
    context: Arc<dyn GuiContext>,

    foo_slider_state: nih_widgets::param_slider::State,

#[derive(Debug, Clone, Copy)]
enum Message {
    /// Update a parameter's value.

impl IcedEditor for FooEditor {
    type Executor = executor::Default;
    type Message = Message;
    type InitializationFlags = Arc<FooParams>;

    fn new(
        params: Self::InitializationFlags,
        context: Arc<dyn GuiContext>,
    ) -> (Self, Command<Self::Message>) {
        let editor = FooEditor {

            foo_slider_state: Default::default(),

        (editor, Command::none())

    fn context(&self) -> &dyn GuiContext {

    fn update(
        &mut self,
        _window: &mut WindowQueue,
        message: Self::Message,
    ) -> Command<Self::Message> {
        match message {
            Message::ParamUpdate(message) => self.handle_param_message(message),


    fn view(&mut self) -> Element<'_, Self::Message> {
                    &mut self.foo_slider_state,


  • pub use iced_baseview::*;


  • Binary assets for use with nih_plug_iced.
  • Widgets and utilities for making widgets to integrate iced with NIH-plug.



  • A plugin editor using iced. This wraps around [Application] with the only change being that the usual new() function now additionally takes a Arc<dyn GuiContext> that the editor can store to interact with the parameters. The editor should have a Arc<impl Params> as part of their InitializationFlags so it can read the current parameter values. See [Application] for more information.


  • Create an Editor instance using iced. The rough idea is that you implement IcedEditor, which is roughly analogous to iced’s regular [Application] trait except that it receives the GuiContext alongside its initialization flags so it can update the parameter values. The IcedState passed to this function contains the GUI’s intitial size, and this is kept in sync whenever the GUI gets resized. You can also use this to know if the GUI is open, so you can avoid performing potentially expensive calculations while the GUI is not open. If you want this size to be persisted when restoring a plugin instance, then you can store it in a #[persist = "key"] field on your parameters struct.